3.0.1
https://github.com/screendriver/vue-cli-worker-loader-bug
Node 10.9.0 / yarn 1.9.4 / macOS high sierra
Just do a yarn serve and open http://localhost:8080 in your browser. You can see the error immediately.
Should not throw Uncaught ReferenceError: window is not defined.
Throws the error and doesn't work.
I ran into similar issues in a worker-loader + webpack-worker-wrapper setup. You can work around it by adding this to your vue.config.js :
module.exports = {
chainWebpack: config => {
config.output.globalObject('this')
}
}
... and doing something like this in your worker.js files :
import workerGlobals from './workerGlobals.js'
and in workerGlobals.js
//Comment the lines you don't need.
global.process = process
window = undefined
this work for me, add to vue.config.js
configureWebpack: {
output: {
globalObject: 'this',
},
},
Oh it works. Great!
Maybe it would be a good idea to include that webpack loader directly into vue cli? 馃
Take a look to #2286!
@Kocal that "just" fixes the issue where I have to add configureWebpack: { output: { globalObject: 'this', }, } manually to my project but not that worker-loader will be add by vue-cli automatically (or via propmt) 馃槈
Most helpful comment
this work for me, add to vue.config.js
configureWebpack: { output: { globalObject: 'this', }, },