Workbox: Output workbox-sw lib as part of build process

Created on 23 Jun 2017  路  4Comments  路  Source: GoogleChrome/workbox

Library Affected:
workbox-build, workbox-sw

Browser & Platform:
All

Issue or Feature Request Description:
I had to "register a route" to handle pretty URLs, so I'm using injectManifest in a custom SW. Right now for my build process, I've installed workbox-sw as a node module, and just copy the prod version from the importScripts directory.

I'd prefer if workbox-build just output the workbox-sw library for me when I inject the manifest. Is there a way to do that?

function buildSw() {
  return wb.injectManifest({
    globDirectory: './_site/',
    globPatterns: ['**\/*'],
    swSrc: './src/sw.js',
    swDest: './_site/sw.js',
  }).then(() => {
    gutil.log('Build Manifest generated.');
  }).catch((error) => {
    gutil.log('Error: ' + error);
  });
}
workbox-build

Most helpful comment

At the moment there isn't. Open to suggestions to what you think would fit your workflow here.

This is for me, the biggest problem with workbox at the moment, getting the library file into your project and / or service worker.

I personally would like to see us encouraging CDN usage instead of pulling the file from NPM, this way you can just import the script with a known CDN and good to go.

All 4 comments

At the moment there isn't. Open to suggestions to what you think would fit your workflow here.

This is for me, the biggest problem with workbox at the moment, getting the library file into your project and / or service worker.

I personally would like to see us encouraging CDN usage instead of pulling the file from NPM, this way you can just import the script with a known CDN and good to go.

This is also a problem with the webpack plugin (see #653)

We plan to add a helper method to copy over either all or some of the workbox files to make this easier.

The copyLibraries helper method and CDN by default should solve this.

Was this page helpful?
0 / 5 - 0 ratings