Skip to content

Commit 6551c8e

Browse files
authored
fix: webpack 3 RuleSet creation (#407)
1 parent 3f0b438 commit 6551c8e

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

lib/util/serial.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,20 @@ const loaders = (exports.loaders = {
7474
ruleSet = extra.compiler.__hardSource_ruleSet;
7575
if (!ruleSet) {
7676
const RuleSet = require('webpack/lib/RuleSet');
77-
ruleSet = extra.compiler.__hardSource_ruleSet = new RuleSet(
78-
extra.compiler.options.module.defaultRules.concat(
79-
extra.compiler.options.module.rules,
80-
),
81-
);
77+
if (extra.compiler.options.module.defaultRules) {
78+
// webpack 4
79+
ruleSet = extra.compiler.__hardSource_ruleSet = new RuleSet(
80+
extra.compiler.options.module.defaultRules.concat(
81+
extra.compiler.options.module.rules,
82+
),
83+
);
84+
} else {
85+
// webpack <4
86+
ruleSet = extra.compiler.__hardSource_ruleSet = new RuleSet(
87+
extra.compiler.options.module.rules ||
88+
extra.compiler.options.module.loaders,
89+
);
90+
}
8291
}
8392
}
8493
return {

0 commit comments

Comments
 (0)