Open jackysee opened 3 years ago
At present, some problems are caused by cache-loader
. I think everything will be better after supporting webpack5, since cache-loader
is deprecated.
For file.worker.js
, the loader used is[cache-loader, babel-loader, worker-loader]
In short.
First build, worker-loader.pitch
will generate file.worker.xx.js
chunk asynchronously.
Second build, cache-loader.pitch
return directly because of cache hit, and worker-loader.pitch
is skipped.
So workaround is changing loader order to [worker-loader, cache-loader, babel-loader]
, so that worker-loader.pitch
won't be skipped.
/** @type {import('@vue/cli-service').ProjectOptions} */
module.exports = {
chainWebpack: config => {
//change this file
config.module
.rule("worker")
+ .before('js')
.test(/worker\.js$/)
.use("worker-loader")
.loader("worker-loader")
.end();
}
};
Version
4.5.8
Reproduction link
https://github.com/jackysee/workertest
Environment info
Steps to reproduce
npm run build
, should see the bundle has a worker file, which is created by the worker-loadernpm run build
again, the worker file is missing.vue.config.js
, add a commentnpm run build
, the worker file appear in the bundle again.What is expected?
The build should be consistent. The worker file should appear in the final bundle in every build.
What is actually happening?
First build
2nd build
Looks like some caching issue here?
vue.config.js
HelloWorld.vue
file.worker.js