1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/server/config.js
Arunoda Susiripala 26c485a22f Add X-Powered-By header. (#416)
* Add X-Powered-By header.

* Add support to disable setting x-provided-by header

* Add some test cases.
2016-12-19 07:27:47 -08:00

31 lines
613 B
JavaScript

import { join } from 'path'
import { existsSync } from 'fs'
const cache = new Map()
const defaultConfig = {
webpack: null,
poweredByHeader: true
}
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)
}