Skip to content

PWA Plugin: Transpile Service Worker #3292

Open
@lukas-tr

Description

@lukas-tr

What 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",
    }
  }
};

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions