Skip to content

Commit

Permalink
fix: undefined is not a function (#168)
Browse files Browse the repository at this point in the history
fixes #167
  • Loading branch information
rti authored Jan 19, 2021
1 parent 59c383b commit 766c034
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/getVueRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@ try {
vueLoaderPath = require.resolve('vue-loader')
} catch (err) {}

function isVueLoader (use) {
return use.ident === 'vue-loader-options' ||
use.loader === 'vue-loader' ||
(vueLoaderPath && use.loader === vueLoaderPath)
}

module.exports = {
isVueLoader (use) {
return use.ident === 'vue-loader-options' ||
use.loader === 'vue-loader' ||
(vueLoaderPath && use.loader === vueLoaderPath)
},
isVueLoader,
getVueRules (compiler) {
const rules = compiler.options.module.rules

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

0 comments on commit 766c034

Please sign in to comment.