papa's avatar
Level 3

Laravel Mix with Vue-loader

I try to use vue-loader with webpack.mix.js without success

My configuration

const mix = require('laravel-mix');
const VueLoaderPlugin = require('vue-loader/lib/plugin');

mix
    .webpackConfig({
        module: {
            rules: [
                {
                    test: /\.vue$/,
                    loader: 'vue-loader'
                }
            ]
        },
        plugins: [
            new VueLoaderPlugin()
        ]
    })
    .js('resources/js/app.js', 'public/js')
    .extract(['vue', 'vee-validate'])
;

The error I get is

Error: [VueLoaderPlugin Error] No matching use for vue-loader is found.
Make sure the rule matching .vue files include vue-loader in its use.

Some support!

0 likes
7 replies
bobbybouwmann's avatar

Can you show your app.js file? It seems you're not using vue-loader correctly there!

papa's avatar
Level 3

@BOBBYBOUWMANN -

window.Vue = require('vue');

// const files = require.context('./', true, /\.vue$/i);
// files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default));

Vue.component('login-form', require('./components/Login.vue').default);


const app = new Vue({
    el: '#app',
    mounted() {
        console.log('asd');
    }
});
JeffreyWay's avatar
Level 59

Mix already uses vue-loader. You don't need to manually pull it in.

2 likes
papa's avatar
Level 3

@JEFFREYWAY - ok thanks let me check, i guess is the problem in my component Login.vue

papa's avatar
Level 3

@BOBBYBOUWMANN - No the error was in my Login.vue file. I use VeeValidate and I should firstly use it

Vue.use(require('vee-validate'));

in my app.js file.

Also I did not know that Mix already use vue-loader so I removed also the webpackConfig which I have posted above.

Thanks

Please or to participate in this conversation.