Skip to content

Instantly share code, notes, and snippets.

@tkssharma
Created August 28, 2019 06:06
Show Gist options
  • Save tkssharma/d6bbcbc65bed527b7ab9f2d1dc8f292b to your computer and use it in GitHub Desktop.
Save tkssharma/d6bbcbc65bed527b7ab9f2d1dc8f292b to your computer and use it in GitHub Desktop.
const {rewireWorkboxInject, defaultInjectConfig} = require('react-app-rewire-workbox');
const path = require('path');
module.exports = function override(config, env) {
if (env === "production") {
console.log("Production build - Adding Workbox for PWAs");
// Extend the default injection config with required swSrc
const workboxConfig = {
...defaultInjectConfig,
swSrc: path.join(__dirname, 'src', 'custom-sw.js')
};
config = rewireWorkboxInject(workboxConfig)(config, env);
}
return config;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment