mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
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)
This commit is contained in:
parent
9c88ea8c58
commit
702dd5d3f4
|
@ -70,6 +70,7 @@
|
|||
"cross-spawn": "5.1.0",
|
||||
"del": "3.0.0",
|
||||
"etag": "1.8.1",
|
||||
"find-up": "2.1.0",
|
||||
"fresh": "0.5.2",
|
||||
"friendly-errors-webpack-plugin": "1.6.1",
|
||||
"glob": "7.1.2",
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { join } from 'path'
|
||||
import { existsSync } from 'fs'
|
||||
import findUp from 'find-up'
|
||||
|
||||
const cache = new Map()
|
||||
|
||||
|
@ -26,12 +25,13 @@ function loadConfig (dir, customConfig) {
|
|||
customConfig.configOrigin = 'server'
|
||||
return withDefaults(customConfig)
|
||||
}
|
||||
const path = join(dir, 'next.config.js')
|
||||
const path = findUp.sync('next.config.js', {
|
||||
cwd: dir
|
||||
})
|
||||
|
||||
let userConfig = {}
|
||||
|
||||
const userHasConfig = existsSync(path)
|
||||
if (userHasConfig) {
|
||||
if (path && path.length) {
|
||||
const userConfigModule = require(path)
|
||||
userConfig = userConfigModule.default || userConfigModule
|
||||
userConfig.configOrigin = 'next.config.js'
|
||||
|
|
Loading…
Reference in a new issue