Skip to content

Commit 702dd5d

Browse files
Inkdpixelsarunoda
authored andcommitted
Resolve the next.config.js up the tree to avoid it not being loaded when a source dir was specified via the CLI - solves vercel#3379 (vercel#3380)
1 parent 9c88ea8 commit 702dd5d

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
"cross-spawn": "5.1.0",
7171
"del": "3.0.0",
7272
"etag": "1.8.1",
73+
"find-up": "2.1.0",
7374
"fresh": "0.5.2",
7475
"friendly-errors-webpack-plugin": "1.6.1",
7576
"glob": "7.1.2",

server/config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { join } from 'path'
2-
import { existsSync } from 'fs'
1+
import findUp from 'find-up'
32

43
const cache = new Map()
54

@@ -26,12 +25,13 @@ function loadConfig (dir, customConfig) {
2625
customConfig.configOrigin = 'server'
2726
return withDefaults(customConfig)
2827
}
29-
const path = join(dir, 'next.config.js')
28+
const path = findUp.sync('next.config.js', {
29+
cwd: dir
30+
})
3031

3132
let userConfig = {}
3233

33-
const userHasConfig = existsSync(path)
34-
if (userHasConfig) {
34+
if (path && path.length) {
3535
const userConfigModule = require(path)
3636
userConfig = userConfigModule.default || userConfigModule
3737
userConfig.configOrigin = 'next.config.js'

0 commit comments

Comments
 (0)