PWA Plugin: Transpile Service Worker
See original GitHub issueWhat problem does this feature solve?
There is an ever-growing list of things that need to be handled in service workers, which can’t be handled in normal web workers (like caching, push notifications, background sync, …) and it would be great to split the code into different files and use typescript, babel, and other loaders to improve the developer experience and type safety.
I can use worker-loader
for web workers, but this loader doesn’t work for service workers.
What does the proposed API look like?
Add a transpile
option to the pwa
config section. When enabled, the service worker is transpiled instead of just copied (similar to worker-loader
). The workbox script and the precache manifest and can be imported in sw.js
via a dummy module (to support typescript).
// vue.config.js
module.exports = {
pwa: {
workboxPluginMode: "InjectManifest",
transpile: true,
workboxOptions: {
swSrc: "src/sw.js",
}
}
};
Issue Analytics
- State:
- Created 5 years ago
- Reactions:10
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Building a Service Worker with Workbox 5, TypeScript ...
The “build:pwa:web” script: Removes the service-worker.js file in the dist/apps/web folder (just in case); Uses production Webpack configuration ...
Read more >plugin-pwa | Docusaurus
This plugin generates a Service Worker in production build only, and allows you to create fully PWA-compliant documentation site with offline ...
Read more >Ultimate Guide to PWAs with Workbox
This post is a complete guide to building a Progressive Web App (PWA) from the beginning using Google's Workbox. By the end of...
Read more >Service worker - Adobe Developer
Service worker. A webpack plugin for configuring a ServiceWorker for different PWA development scenarios. This plugin is a wrapper around the Google Workbox ......
Read more >Custom Service Worker Logic in Typescript on Vite
Do the Service Worker Transpilation & Bundling as a Vite Plugin. Transpiling and bundling Typescript code as a single Javascript file can easily ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We will upgrade to workbox’s new major in our next major upgrade, yes.
There’s still an open issue about this in the workbox repo: https://github.com/GoogleChrome/workbox/issues/1513
Do we want to work around that in some way, and if so, is there an idea how to achieve that?