webpack - VueLoaderPlugin 错误 : No matching use for vue-loader is found

标签 webpack

我在 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/

相关文章:

javascript - 如何使用 Webpack 和 Babel 通过 Karma 从代码覆盖率中排除 Spec 文件?

javascript - 带有 Angular 2、D3 和 Vizuly 的第三方库

node.js - Webpack:找不到模块:错误:无法解析模块 browser.js

javascript - 使用 Webpack 时如何在 Service Worker 中导入脚本

typescript - 在 TS 3.2.2 中使用 --isolatedModules 时无法重新导出类型

typescript - 如何在 webpack 中使用 underscore.js

node.js - 将 Pug 与 NodeJS 和 Webpack 结合使用

css - MiniCssExtractPlugin 是乱码和混淆我的类名

webpack - 将 PrimeNG 与 JHipster 集成的步骤

node.js - 如何在 webpack 编译期间禁止替换 process.env 变量?