【发布时间】:2020-01-15 16:22:38
【问题描述】:
我在 Laravel Mix 项目中使用 webpack。当我的 webpack.config.js 看起来像这样时,Webpack 可以正常工作:
module.exports = {
module: {
rules: [{ test: /\.vue$/, loader: 'vue-loader' }]
}
}
但是当我像这样添加 VueLoaderPlugin 时:
const VueLoaderPlugin = require('vue-loader/lib/plugin');
module.exports = {
module: {
rules: [{ test: /\.vue$/, loader: 'vue-loader' }]
},
plugins: [
// make sure to include the plugin for the magic
new VueLoaderPlugin()
]
}
我收到此错误:
Error: [VueLoaderPlugin Error] No matching use for vue-loader is found.
Make sure the rule matching .vue files include vue-loader in its use.
这没有意义,因为我已经准备好包含 vue-loader 的 .vue 规则。这是什么问题,我该如何解决?
【问题讨论】:
-
我在尝试制作 vue-styleguidist 时遇到了同样的问题(相同的 webpack 配置)
-
查看 vue-loader 设置手册
https://vue-loader.vuejs.org/guide/#manual-setup主要区别是导入/需要vue-loader本身而不是vue-loader/lib/plugin
标签: webpack