Setting Webpack Terser settings for build
-
I have a pwa quasar application. I use codefresh to build it. This is a simular service to circleCI.
I see the error:App · Compiling PWA... App · Compiled PWA done in 108943 ms App · ⚠️ 1 error encountered: js/vendor.4c4ee126.js from Terser Error: Call retries were exceeded - ChildProcessWorker.js:193 ChildProcessWorker.initialize [frontend]/[jest-worker]/build/workers/ChildProcessWorker.js:193:21 - ChildProcessWorker.js:274 ChildProcessWorker._onExit [frontend]/[jest-worker]/build/workers/ChildProcessWorker.js:274:12 - child_process.js:248 Process.ChildProcess._handle.onexit internal/child_process.js:248:12
My guess is I am suffering from this issue:
https://github.com/webpack-contrib/terser-webpack-plugin/issues/202The fix aparantly is to specify parallel in my webpack.config.js Something like as follows:
module.exports = { optimization: { minimize: true, minimizer: [ new TerserPlugin({ parallel: 1, }), ], }, };
That’s find but Quasar dosen’t seem to have a webpack.config.js.
I have used the commandquasar inspect -m pwa
To see it but when I search this output I can’t find any reference to Terser or parallel.
I have read through https://quasar.dev/quasar-cli/handling-webpack#introduction but it is not clear to me how providing a extendWebpack function changes the webpack configuration file.
I also think I need to add the line
const TerserPlugin = require("terser-webpack-plugin");
somewhere but have no idea where. (Maybe in the extendWebpack function??)
Any pointers would be apreciated.
Robert -
I managed to resolve my own issue with a bit of a hailmary guess.
First I added this to the top of quasar.conf.js:
const TerserPlugin = require("terser-webpack-plugin");
Next I added the following to the build section
extendWebpack (cfg) { cfg.optimization.minimize = true cfg.optimization.minimizer = [new TerserPlugin({ parallel: 1 })] }
I then ran my deployment process on codefresh and it worked!
That took a lot of trail and error to get to. Hopefully this post will be helpful for someone else.