Skip to content

A simple craco plugin to override the workbox config in CRA2

License

Notifications You must be signed in to change notification settings

kevinsperrine/craco-workbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

craco-workbox

Prerequisites

Install craco

Install

yarn add craco-workbox -D

# OR

npm install craco-workbox -S

Usage

  1. Add the plugin into your craco.config.js;
// craco.config.js

const CracoWorkboxPlugin = require('craco-workbox');

module.exports = {
    plugins: [{
        plugin: CracoWorkboxPlugin
    }]
}
  1. 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.
// 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 for more information.