Skip to content

Commit

Permalink
Fix: #1779 VueLoaderPlugin cause webpack5 Rule.use configuration to b…
Browse files Browse the repository at this point in the history
…e lost
  • Loading branch information
fredgan committed Dec 29, 2020
1 parent 1c2436a commit fb9e5b4
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions lib/plugin-webpack5.js
Expand Up @@ -151,22 +151,6 @@ function cloneRule (rawRule, refs) {
// shallow flat
.reduce((prev, next) => prev.concat(next), [])

// do not process rule with enforce
if (!rawRule.enforce) {
const ruleUse = rules[0].rules
.map(rule => rule.effects
.filter(effect => effect.type === 'use')
.map(effect => effect.value)
)
// shallow flat
.reduce((prev, next) => prev.concat(next), [])

// fix conflict with config.loader and config.options when using config.use
delete rawRule.loader
delete rawRule.options
rawRule.use = ruleUse
}

const res = Object.assign({}, rawRule, {
resource: resources => {
currentResource = resources
Expand All @@ -193,6 +177,22 @@ function cloneRule (rawRule, refs) {
}
})

// do not process rule with enforce
if (!res.enforce) {
const ruleUse = rules[0].rules
.map(rule => rule.effects
.filter(effect => effect.type === 'use')
.map(effect => effect.value)
)
// shallow flat
.reduce((prev, next) => prev.concat(next), [])

// fix conflict with config.loader and config.options when using config.use
delete res.loader
delete res.options
res.use = ruleUse
}

delete res.test

if (rawRule.rules) {
Expand Down

0 comments on commit fb9e5b4

Please sign in to comment.