Laravel-mix: Uncaught ReferenceError: Vue is not defined

Created on 7 May 2017  路  3Comments  路  Source: JeffreyWay/laravel-mix

In my webpack mix file I have set .extract(['vue',...

Then
mix.autoload({ validator: ['validator', 'window.validator'], vue: ['window.Vue', 'Vue'] });

And lastly removed any Vue refrence in app.js and bootstrap.js

But now when I try to use Vue in other js files I still get the error: Uncaught ReferenceError: Vue is not defined

So how can I exctract Vue and still use it in other files like: var app = new Vue({...

Most helpful comment

Keep your Vue settings as per factory default for Laravel-Mix, which is to leave window.Vue = require('vue') inside bootstrap.js

It worked for me and probably many others too.

All 3 comments

Keep your Vue settings as per factory default for Laravel-Mix, which is to leave window.Vue = require('vue') inside bootstrap.js

It worked for me and probably many others too.

Same problem here, how are you supposed to autoload vue it is really confusing, I am getting Vue undefined regardless of the approach followed

vue: ['Vue', 'window.Vue']
or
'vue/dist/vue.esm.js': ['Vue', 'window.Vue']
or
should I use provideplugin for this like

mix.webpackConfig({
plugins: [
new webpack.ProvidePlugin({
Vue: ["vue/dist/vue.esm.js", "default"]
})
]
});

I have NOT import Vue in my app.js file because I am guessing autoload will inject a global Vue component, I have a console.log(Vue.length) just to ensure that Vue is not excluded though
Should I import Vue from vue after doing autoload as well
Should I also add window.Vue = Vue
Some clarification would be really apprecaited

@slidenerd I have the same confusion as you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RomainGoncalves picture RomainGoncalves  路  3Comments

dtheb picture dtheb  路  3Comments

pixieaka picture pixieaka  路  3Comments

rlewkowicz picture rlewkowicz  路  3Comments

mementoneli picture mementoneli  路  3Comments