-
Notifications
You must be signed in to change notification settings - Fork 2
/
next.config.js
66 lines (59 loc) · 1.93 KB
/
next.config.js
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
output: "standalone",
// need to include(trace) these files, because next cannot determine whether they are important
// this option doesn't seem to work, so copy them manually in dockerfile
// unstable_includeFiles: ["./dynamicCache.json", "./defaultDynamicCache.json"]
};
// const withTM = require("next-transpile-modules")(["evergreen-org-crawler"]);
// const config = require('config'); // in case of using node-config
const config = require("./config.json");
function MergeCustomConfig(customConfigFileName) {
const fs = require("fs");
const DefaultConfigFileName = "./config.json";
const DefaultConfig = JSON.parse(
fs.readFileSync(DefaultConfigFileName, "utf-8")
);
let MergedConfigs = DefaultConfig;
if (fs.existsSync(customConfigFileName)) {
try {
const customConfig = JSON.parse(
fs.readFileSync(customConfigFileName, "utf-8")
);
// TODO: check the validity of the values in custom config
for (const [key, value] of Object.entries(customConfig)) {
if (!DefaultConfig[key]) {
console.warn(
`Ignoring invalid key "${key}" found in ${customConfigFileName}`
);
}
}
// Overwrite default configs with the custom ones
MergedConfigs = { ...DefaultConfig, ...customConfig };
} catch (e) {
throw new Error(
`Could not load custom configs from ${customConfigFileName}: ${e}`
);
}
}
return MergedConfigs;
}
// const CustomConfigFileName = "./customConfig.json";
// const evergreenConfig = MergeCustomConfig(CustomConfigFileName);
// console.log(evergreenConfig)
module.exports = {
publicRuntimeConfig: {
...config,
},
webpack5: true,
webpack(config) {
config.module.rules.push({
test: /\.svg$/i,
issuer: /\.[jt]sx?$/,
use: ["@svgr/webpack"],
});
return config;
},
...nextConfig,
};