https://github.com/kevinsperrine/craco-workbox
A simple craco plugin to override the workbox config in CRA2
https://github.com/kevinsperrine/craco-workbox
craco create-react-app-v2 service-worker workbox workbox-webpack-plugin
Last synced: 2 months ago
JSON representation
A simple craco plugin to override the workbox config in CRA2
- Host: GitHub
- URL: https://github.com/kevinsperrine/craco-workbox
- Owner: kevinsperrine
- License: mit
- Created: 2019-02-07T02:40:29.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2021-10-13T14:30:35.000Z (over 4 years ago)
- Last Synced: 2025-08-09T03:51:35.183Z (9 months ago)
- Topics: craco, create-react-app-v2, service-worker, workbox, workbox-webpack-plugin
- Language: JavaScript
- Size: 58.6 KB
- Stars: 19
- Watchers: 1
- Forks: 5
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# craco-workbox
**Prerequisites**
Install [craco](https://github.com/sharegate/craco)
## Install
```
yarn add craco-workbox -D
# OR
npm install craco-workbox -S
```
## Usage
1. Add the plugin into your craco.config.js;
```javascript
// craco.config.js
const CracoWorkboxPlugin = require('craco-workbox');
module.exports = {
plugins: [{
plugin: CracoWorkboxPlugin
}]
}
```
2. Add a workbox.config.js file to your project root containing the overrides you would like to pass. For a full list of options see [https://developers.google.com/web/tools/workbox/modules/workbox-webpack-plugin#generatesw_plugin](https://developers.google.com/web/tools/workbox/modules/workbox-webpack-plugin#generatesw_plugin).
```javascript
// workbox.config.js
module.exports = {
GenerateSW: options => {
// override GenerateSW config here
// e.g. options.skipWaiting = true;
return options;
},
InjectManifest: options => {
// override InjectManifest config here
// e.g. options.maximumFileSizeToCacheInBytes = 10 * 1024 * 1024;
return options;
}
};
```
## License
Licensed under the MIT License, Copyright ©️ 2019 Kevin S. Perrine. See [LICENSE](LICENSE) for more information.