Commit 702dd5d3 authored by Tyll Weiß's avatar Tyll Weiß Committed by Arunoda Susiripala

Resolve the next.config.js up the tree to avoid it not being loaded when a…

Resolve the next.config.js up the tree to avoid it not being loaded when a source dir was specified via the CLI - solves #3379 (#3380)
parent 9c88ea8c
...@@ -70,6 +70,7 @@ ...@@ -70,6 +70,7 @@
"cross-spawn": "5.1.0", "cross-spawn": "5.1.0",
"del": "3.0.0", "del": "3.0.0",
"etag": "1.8.1", "etag": "1.8.1",
"find-up": "2.1.0",
"fresh": "0.5.2", "fresh": "0.5.2",
"friendly-errors-webpack-plugin": "1.6.1", "friendly-errors-webpack-plugin": "1.6.1",
"glob": "7.1.2", "glob": "7.1.2",
......
import { join } from 'path' import findUp from 'find-up'
import { existsSync } from 'fs'
const cache = new Map() const cache = new Map()
...@@ -26,12 +25,13 @@ function loadConfig (dir, customConfig) { ...@@ -26,12 +25,13 @@ function loadConfig (dir, customConfig) {
customConfig.configOrigin = 'server' customConfig.configOrigin = 'server'
return withDefaults(customConfig) return withDefaults(customConfig)
} }
const path = join(dir, 'next.config.js') const path = findUp.sync('next.config.js', {
cwd: dir
})
let userConfig = {} let userConfig = {}
const userHasConfig = existsSync(path) if (path && path.length) {
if (userHasConfig) {
const userConfigModule = require(path) const userConfigModule = require(path)
userConfig = userConfigModule.default || userConfigModule userConfig = userConfigModule.default || userConfigModule
userConfig.configOrigin = 'next.config.js' userConfig.configOrigin = 'next.config.js'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment