JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 8
  • Score
    100M100P100Q55368F
  • License MIT

The sw-builder package automates the creation of your Application's Service Worker, which pre-caches your build. This leads to a better overall performance and enables users to access your PWA without an Internet connection.

Package Exports

  • sw-builder
  • sw-builder/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sw-builder) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Service Worker Builder

The sw-builder package automates the creation of your Application's Service Worker, which pre-caches your build. This leads to a better overall performance and enables users to access your PWA without an Internet connection.


Getting Started

Install the package:

$ npm install -D sw-builder

Create the sw-builder.config.json file in your project's root:

{
  "outDir": "dist",
  "template": "base",
  "includeToPrecache": [
    "/assets",
    "/some-other-dir",
    "/index.html",
    "/logo.png",
    "/splash.png"
  ],
  "excludeFilesFromPrecache": [
    "some-ignorable-file.woff2",
  ]
}

Include the sw-builder binary in your package.json file:

...
"scripts": {
  "build": "tsc && ... && sw-builder",
  
  // specify a custom path for the configuration file
  "build": " tsc && ... && sw-builder --config='sw-custom.config.json'",
}
...

If you are using Vite include an empty sw.js file in your public directory so you can test the Service Worker's Registration while developing.


Built With

  • TypeScript

Running the Tests

# Unit Tests
$ npm run test:unit

# Integration Tests
$ npm run test:integration

License

MIT


Acknowledgments


Deployment

Install dependencies:

$ npm install

Build the project:

$ npm start

Publish to npm:

$ npm publish