VueLoaderPlugin 错误:找不到与 vue-loader 匹配的用法 [英] VueLoaderPlugin Error: No matching use for vue-loader is found

查看:34
本文介绍了VueLoaderPlugin 错误:找不到与 vue-loader 匹配的用法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Laravel Mix 项目中使用 webpack.当我的 webpack.config.js 看起来像这样时,Webpack 可以正常工作:

I am using webpack within a Laravel Mix project. When my webpack.config.js looks like this, Webpack works without error:

module.exports = {
    module: {
        rules: [{ test: /\.vue$/, loader: 'vue-loader' }]
    }
}

但是当我像这样添加 VueLoaderPlugin 时:

But when I add VueLoaderPlugin like so:

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 规则.这里有什么问题,我该如何解决?

Which doesn't make sense since I ready have a .vue rule that includes vue-loader. What is the problem here, and how do I resolve it?

推荐答案

您的 Laravel mix 设置已经隐式加载了 VueLoaderPlugin,因此再次重新加载会导致此错误.

The Laravel mix setup of yours already loads the VueLoaderPlugin implicitly, so reloading it again causes this error.

通过阅读他们的文档,它写道他们支持 .vue 文件编译,无需额外配置.

From reading their docs, it written that they support .vue file compilation without extra configuration.

如果您仍然不相信,请查看他们的内部网络包配置:https://www.github.com/JeffreyWay/laravel-mix/tree/master/src%2Fcomponents%2FVue.js并注意 VueLoaderPlugin 的使用.

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.

这篇关于VueLoaderPlugin 错误:找不到与 vue-loader 匹配的用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆