From 766c034af46fbcedbd8873382dc432fd182b7938 Mon Sep 17 00:00:00 2001 From: rti Date: Tue, 19 Jan 2021 07:24:15 +0100 Subject: [PATCH] fix: undefined is not a function (#168) fixes #167 --- lib/getVueRules.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/getVueRules.js b/lib/getVueRules.js index a8ad06a..d9c1bfd 100644 --- a/lib/getVueRules.js +++ b/lib/getVueRules.js @@ -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)) } }