我在 Laravel Mix 项目中使用 webpack。当我的 webpack.config.js 看起来像这样时,Webpack 可以正常工作:
module.exports = {
module: {
rules: [{ test: /\.vue$/, loader: 'vue-loader' }]
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我像这样添加 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()
]
}
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
Error: [VueLoaderPlugin Error] No matching use for vue-loader is found.
Make sure the rule matching .vue files include vue-loader in its use.
Run Code Online (Sandbox Code Playgroud)
这没有意义,因为我已经准备好包含 vue-loader 的 .vue 规则。这里有什么问题,我该如何解决?
您的 Laravel 混合设置已经隐式加载了 VueLoaderPlugin,因此再次重新加载会导致此错误。
通过阅读他们的文档,它写道他们支持 .vue 文件编译而无需额外配置。
If you're still not convinced, check out their internal web pack configuration: https://www.github.com/JeffreyWay/laravel-mix/tree/master/src%2Fcomponents%2FVue.js and notice the use of VueLoaderPlugin.
| 归档时间: |
|
| 查看次数: |
10291 次 |
| 最近记录: |