Skip to content

Commit

Permalink
fix: add check before calling find on vue rule (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dom Corvasce committed Mar 9, 2021
1 parent d5446df commit 22e2492
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/getVueRules.js
@@ -1,6 +1,3 @@

const webpack = require('webpack')

let vueLoaderPath
try {
vueLoaderPath = require.resolve('vue-loader')
Expand All @@ -18,9 +15,9 @@ module.exports = {
const rules = compiler.options.module.rules

// Naive approach without RuleSet or RuleSetCompiler
rules.map((rule, i) => rule.use && rule.use.find(isVueLoader) ? i : null).filter(v => v != null)
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(isVueLoader))
return rules.filter(rule => rule.use && rule.use.find && rule.use.find(isVueLoader))
}
}

0 comments on commit 22e2492

Please sign in to comment.