Skip to content

Commit

Permalink
fix: clone rules before adding oneOf
Browse files Browse the repository at this point in the history
  • Loading branch information
KaelWD authored and VladBarabash committed Feb 14, 2022
1 parent b79d600 commit 6dba152
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dev5/webpack.config.js
Expand Up @@ -88,7 +88,7 @@ module.exports = {
}

if (isProd) {
module.exports.devtool = '#source-map'
module.exports.devtool = 'source-map'
// http://vue-loader.vuejs.org/en/workflow/production.html
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.DefinePlugin({
Expand Down
9 changes: 5 additions & 4 deletions lib/getVueRules.js
Expand Up @@ -15,9 +15,10 @@ module.exports = {
const rules = compiler.options.module.rules

// Naive approach without RuleSet or RuleSetCompiler
rules.map((rule, i) => rule.use && rule.use.find && rule.use.find(isVueLoader) ? i : null).filter(v => v != null)

// find the rules that apply to vue files
return rules.filter(rule => rule.use && rule.use.find && rule.use.find(isVueLoader))
return rules.map((rule, index) => (
rule.use && rule.use.find && rule.use.find(isVueLoader)
? { rule: { ...rule }, index }
: null
)).filter(v => v != null)
}
}
8 changes: 7 additions & 1 deletion lib/plugin.js
Expand Up @@ -20,6 +20,12 @@ class VuetifyLoaderPlugin {

vueRules.forEach(this.updateVueRule.bind(this))

const rules = [...compiler.options.module.rules]
vueRules.forEach(({ rule, index }) => {
rules[index] = rule
})
compiler.options.module.rules = rules

if (this.options.progressiveImages) {
const options = typeof this.options.progressiveImages === 'boolean'
? undefined
Expand Down Expand Up @@ -52,7 +58,7 @@ class VuetifyLoaderPlugin {
}
}

updateVueRule (rule) {
updateVueRule ({ rule }) {
if (this.options.progressiveImages) {
const vueLoaderOptions = rule.use.find(isVueLoader).options
vueLoaderOptions.compilerOptions = vueLoaderOptions.compilerOptions || {}
Expand Down

0 comments on commit 6dba152

Please sign in to comment.