-
Notifications
You must be signed in to change notification settings - Fork 14
/
next.config.js
42 lines (38 loc) · 1.02 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
module.exports = {
webpack: (config, { dev }) => {
if (process.env.BUNDLE_CHECK) {
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer")
.BundleAnalyzerPlugin;
config.plugins.push(
new BundleAnalyzerPlugin({
analyzerMode: "static"
})
);
}
const originalEntry = config.entry;
config.entry = async () => {
const entries = await originalEntry();
if (entries["main.js"]) {
entries["main.js"].unshift("./utils/polyfills.js");
}
return entries;
};
if (dev) {
config.module.rules.push({
test: /\.js$/,
exclude: [/node_modules/, /lib/],
loader: "eslint-loader",
options: {
// Emit errors as warnings for dev to not break webpack build.
// Eslint errors are shown in console for dev, yay :-)
emitWarning: dev
}
});
}
config.node = {
// Fixes npm packages that depend on `fs` module
fs: "empty"
};
return config;
}
};