vite-pwa / vite-plugin-pwa

Zero-config PWA for Vite
https://vite-pwa-org.netlify.app/
MIT License
3.12k stars 205 forks source link

Minified output #8

Closed azamat-sharapov closed 3 years ago

azamat-sharapov commented 3 years ago

Service worker and Workbox javascript files are not minified. Is there any option I should add or is it missing this feature?

antfu commented 3 years ago

That's a good point, would you mind to create a PR for it? We use https://www.npmjs.com/package/rollup-plugin-workbox underhood and I guess there should be an option for that (we can make it default to minified and configurable for users to opt-out). Thanks

azamat-sharapov commented 3 years ago

It turns out generateSW() already minifies output, if mode options is set to "production". The problem is when building, tsup replaces process.env variables, so mode option always set to "development". Quick fix for this is to pass mode: process.env.NODE_ENV via workbox option to VitePWA. Ideally though, tsup should not touch process.env.NODE_ENV piece.