-
Notifications
You must be signed in to change notification settings - Fork 5
/
next.config.js
35 lines (29 loc) · 949 Bytes
/
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
module.exports = {
webpack: (config) => {
let oneOfRules = config.module.rules.find((x) => x.oneOf).oneOf;
// remove the webpack rule to error on global css/scss
oneOfRules = oneOfRules.filter(
(x) => x.issuer || !x.use || x.use.loader !== "error-loader"
);
// modify the webpack rule targeting only *.module.scss to target only *.scss
const newScssRule = oneOfRules.find(
(x) => x.test && x.test.toString() === /\.module\.(scss|sass)$/.toString()
);
newScssRule.test = /\.(scss|sass)$/;
newScssRule.sideEffects = true;
if (newScssRule.use[0].options.modules) {
newScssRule.use[0].options.modules = false;
}
if (newScssRule.use[1].options.modules) {
newScssRule.use[1].options.modules = false;
}
config.module.rules.splice(
config.module.rules.findIndex((x) => x.oneOf),
1,
{
oneOf: oneOfRules
}
);
return config;
}
};