Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jesusgraterol/sw-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.
https://github.com/jesusgraterol/sw-builder
api app cache gui interface progressive progressive-web-application pwa service-worker sw user-interface web web-api
Last synced: about 2 months ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/jesusgraterol/sw-builder
- Owner: jesusgraterol
- License: mit
- Created: 2024-05-11T14:24:41.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-05-28T19:44:34.000Z (7 months ago)
- Last Synced: 2024-07-06T09:59:03.991Z (6 months ago)
- Topics: api, app, cache, gui, interface, progressive, progressive-web-application, pwa, service-worker, sw, user-interface, web, web-api
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/sw-builder
- Size: 214 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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:
```bash
$ npm install -D sw-builder
```Create the `sw-builder.config.json` file in your project's root:
```json
{
"outDir": "dist",
"template": "base",
"includeToPrecache": [
"/assets",
"/some-other-dir",
"/index.html",
"/logo.png",
"/splash.png"
],
"excludeFilesFromPrecache": [
"some-ignorable-file.woff2"
],
"excludeMIMETypesFromCache": [
"application/json",
"text/plain"
]
}
```Include the `sw-builder` binary in your `package.json` file:
```json
...
"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](https://vitejs.dev/) 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
```bash
# Unit Tests
$ npm run test:unit# Integration Tests
$ npm run test:integration
```
## License
[MIT](https://choosealicense.com/licenses/mit/)
## Acknowledgments
- [Service Worker API | MDN](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API)
- [Introduction to Service Workers | PWAbuilder](https://docs.pwabuilder.com/#/home/sw-intro)
- [Service workers | web.dev](https://web.dev/learn/pwa/service-workers)
## Deployment
Install dependencies:
```bash
$ npm install
```Build the project:
```bash
$ npm start
```Publish to `npm`:
```bash
$ npm publish
```