Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cyyyu/parcel-plugin-sw-precache
A Parcel plugin for generating a service worker that precaches resources.
https://github.com/cyyyu/parcel-plugin-sw-precache
parcel parcel-plugin pwa service-worker
Last synced: 3 months ago
JSON representation
A Parcel plugin for generating a service worker that precaches resources.
- Host: GitHub
- URL: https://github.com/cyyyu/parcel-plugin-sw-precache
- Owner: cyyyu
- License: mit
- Created: 2018-02-01T16:09:49.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-01T20:40:30.000Z (almost 2 years ago)
- Last Synced: 2024-07-20T23:54:18.735Z (4 months ago)
- Topics: parcel, parcel-plugin, pwa, service-worker
- Language: JavaScript
- Size: 99.6 KB
- Stars: 73
- Watchers: 3
- Forks: 9
- Open Issues: 8
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
- awesome-parcel - SW Precache
README
# parcel-plugin-sw-precache
[![npm version](https://badge.fury.io/js/parcel-plugin-sw-precache.svg)](https://badge.fury.io/js/parcel-plugin-sw-precache)
A Parcel plugin for generating a service worker that precaches resources.
### Usage(Install)
`npm install --save-dev parcel-plugin-sw-precache`
### Configurations
You DON'T have to configure anything to get it work. It just works as you expected after you installed.
Every time you build resources with Parcel, it will generate a `service-worker.js` file for you.
Internally it is using [sw-precache](https://github.com/GoogleChromeLabs/sw-precache)
If you want to configure `sw-precache`, you can supply the configs by adding them in your `package.json` within the key `sw-precache`. See all available options at: https://github.com/GoogleChromeLabs/sw-precache#options-parameter
Additionally this plugin have the option "**additionalCodeFile**" if you want to add anything to your service-worker.js (for example a new event-handler). Add a filename relative to the entrypoint specified to Parcel.
For example:
```
{
"name": "my-project",
"version": "0.1.0",
...// my sw-precache configs
"sw-precache": {
"maximumFileSizeToCacheInBytes": 10485760,
"additionalCodeFile": "addSome.js"
}
}
```
**Note:** only files with the following extensions will be added to the precache :
`js, html, css, png, jpg, gif, svg, eot, ttf, woff, woff2, ogg, wav, mp3, wasm, webp, pdf`### License
MIT