我在 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 规则。这里有什么问题,我该如何解决?
最佳答案
您的 Laravel 混合设置已经隐式加载了 VueLoaderPlugin,因此再次重新加载会导致此错误。
通过阅读他们的文档,它写道他们支持 .vue 文件编译而无需额外配置。
如果您仍然不相信,请查看他们的内部网络包配置:https://www.github.com/JeffreyWay/laravel-mix/tree/master/src%2Fcomponents%2FVue.js
并注意 VueLoaderPlugin 的使用。
关于webpack - VueLoaderPlugin 错误 : No matching use for vue-loader is found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57929598/