This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccountGUI/node_modulesOLD/vuetify-loader/lib/plugin.js

34 lines
916 B
JavaScript
Raw Permalink Normal View History

2019-08-11 18:48:02 +00:00
const RuleSet = require('webpack/lib/RuleSet')
class VuetifyLoaderPlugin {
constructor (options) {
this.options = options
}
apply (compiler) {
// use webpack's RuleSet utility to normalize user rules
const rawRules = compiler.options.module.rules
const { rules } = new RuleSet(rawRules)
// find the rule that applies to vue files
let vueRuleIndex = rules.findIndex(rule => rule.use && rule.use.find(u => u.loader === 'vue-loader'))
const vueRule = rules[vueRuleIndex]
if (!vueRule) {
throw new Error(
`[VuetifyLoaderPlugin Error] No matching rule for vue-loader found.\n` +
`Make sure there is at least one root-level rule that uses vue-loader.`
)
}
vueRule.use.unshift({
loader: require.resolve('./loader'),
options: this.options
})
compiler.options.module.rules = rules
}
}
module.exports = VuetifyLoaderPlugin