Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add check before calling find on vue rule #170

Merged
merged 1 commit into from Mar 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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))
}
}