-
Notifications
You must be signed in to change notification settings - Fork 23
/
next.config.js
59 lines (54 loc) · 1.45 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
const { PHASE_DEVELOPMENT_SERVER } = require("next/constants");
const withCSS = require("@zeit/next-css");
const webpack = require("webpack");
module.exports = phase => {
return (withCSS({
experimental: {
optimizeFonts: phase !== PHASE_DEVELOPMENT_SERVER
},
webpack(config, options) {
config.plugins.push(
new webpack.DefinePlugin({
"process.env.DEV": JSON.stringify(options.dev),
IN_BROWSER: !options.isServer,
IS_DEV: options.dev
})
);
config.module.rules.unshift(
{
test: /\.worker\.ts/,
use: {
loader: "worker-loader",
options: { inline: 'fallback' }
}
},
{
test: /\.svg$/,
use: [
{
loader: "@svgr/webpack",
options: {
svgoConfig: {
plugins: {
removeViewBox: false
}
}
}
},
{
loader: "url-loader"
}
]
}
);
config.output.globalObject = 'typeof self !== "object" ? self : this';
// Temporary fix for https://github.com/zeit/next.js/issues/8071
config.plugins.forEach(plugin => {
if (plugin.definitions && plugin.definitions["typeof window"]) {
delete plugin.definitions["typeof window"];
}
});
return config;
}
}));
};