Skip to content

Commit

Permalink
fix isVueLoader undefined (closes vuetifyjs#167)
Browse files Browse the repository at this point in the history
Accessing isVueLoader in exports did not work, therefor this patch
defines the function first and adds it to the exports afterwards.
  • Loading branch information
rti committed Jan 18, 2021
1 parent 59c383b commit 0671576
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 0671576

Please sign in to comment.