-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
37 lines (32 loc) · 1.08 KB
/
index.js
File metadata and controls
37 lines (32 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const defaultServerKey = "serverRuntimeConfig";
const defaultPublicKey = "publicRuntimeConfig";
module.exports = (nextConfig = {}) => {
const config = require("config");
const {
nodeConfigServerKey = defaultServerKey,
nodeConfigPublicKey = defaultPublicKey
} = nextConfig;
return Object.assign({}, nextConfig, {
serverRuntimeConfig: Object.assign(
{},
nextConfig.serverRuntimeConfig,
config[nodeConfigServerKey]
),
publicRuntimeConfig: Object.assign(
{},
nextConfig.publicRuntimeConfig,
config[nodeConfigPublicKey],
nodeConfigServerKey === defaultServerKey ? null : { nodeConfigServerKey },
nodeConfigPublicKey === defaultPublicKey ? null : { nodeConfigPublicKey }
),
webpack(config, options) {
config.resolve = config.resolve || {};
config.resolve.alias = config.resolve.alias || {};
config.resolve.alias.config$ = require.resolve("./config");
if (typeof nextConfig.webpack === "function") {
return nextConfig.webpack(config, options);
}
return config;
}
});
};