[Vuejs]-PWA using Vuejs with webpack: how to minify service worker code?

0๐Ÿ‘

โœ…

I ended up writing my own Webpack plugin. This plugin will:

  1. Activate before any other plugin
  2. Gather Vue environment variables (provcess.env.VUE_APP_*)
  3. Merge together all the files + environment variables needed by the service worker (instead of using ImportScripts). Mangling the files separately wont work, hence this step.
  4. Run Terser on the merged file.
  5. Copy the result to the public folder so it picked up by Webpack normal build process.

I will push the code here once it is cleaned-upโ€ฆ.

Leave a comment