Skip to content

Instantly share code, notes, and snippets.

@jeffposnick
Created September 27, 2019 13:53
Show Gist options
  • Save jeffposnick/571b9e22576c5b6e97715e394be99bce to your computer and use it in GitHub Desktop.
Save jeffposnick/571b9e22576c5b6e97715e394be99bce to your computer and use it in GitHub Desktop.
Example of using importScriptsViaChunks
import {registerRoute} from 'workbox-routing/registerRoute';
registerRoute('/path', yourHandlerCode);
const path = require('path');
const {GenerateSW} = require('workbox-webpack-plugin');
const config = {
mode: 'production',
entry: {
main: path.resolve(__dirname, 'src', 'main.js'),
customWBCode: path.resolve(__dirname, 'src', 'custom-wb-code.js'),
},
output: {
path: path.resolve(__dirname, 'build'),
filename: '[name].js',
},
plugins: [
new GenerateSW({
importScriptsViaChunks: ['customWBCode'],
swDest: 'sw.js',
}),
],
};
module.exports = config;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment