mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
9347c8bdd0
* Update references to `.next` * Remove console logs and extraneous semi colons * Remove lint errors * Update references to .next and update docs * Update options from nested to flat with `distDir` * Add integration tests, and update `.gitignore` * Rename integration folder to dist-dir to match standards
32 lines
633 B
JavaScript
32 lines
633 B
JavaScript
import { join } from 'path'
|
|
import { existsSync } from 'fs'
|
|
|
|
const cache = new Map()
|
|
|
|
const defaultConfig = {
|
|
webpack: null,
|
|
poweredByHeader: true,
|
|
distDir: '.next'
|
|
}
|
|
|
|
export default function getConfig (dir) {
|
|
if (!cache.has(dir)) {
|
|
cache.set(dir, loadConfig(dir))
|
|
}
|
|
return cache.get(dir)
|
|
}
|
|
|
|
function loadConfig (dir) {
|
|
const path = join(dir, 'next.config.js')
|
|
|
|
let userConfig = {}
|
|
|
|
const userHasConfig = existsSync(path)
|
|
if (userHasConfig) {
|
|
const userConfigModule = require(path)
|
|
userConfig = userConfigModule.default || userConfigModule
|
|
}
|
|
|
|
return Object.assign({}, defaultConfig, userConfig)
|
|
}
|