googlearchive / workbox-microsite

Workbox Microsite
Apache License 2.0
24 stars 13 forks source link

webpack plugin documentation lacks configuration info #108

Closed blikblum closed 6 years ago

blikblum commented 6 years ago

I was looking how to configure caching of a CDN resource with the webpack plugin

First looked at webpack get started but no clues how do it

Than looked at CDN How To but the info seems to be for an outdated library version

After digging a bit i found the plugin reference which hints that the options is the same passed to workbox-build

Finally in workbox-build reference i found the runtimeCaching option, so i could simple do:

new WorkboxPlugin({
      globDirectory: DIST_DIR,
      globPatterns: ['**/*.{html,js,css}'],
      swDest: path.join(DIST_DIR, 'sw.js'),
      runtimeCaching: [{
        urlPattern: /^https:\/\/fonts.googleapis.com/,
        handler: 'cacheFirst'
      }]
    })

I hope this report helps improving the docs for new users.

johnnyreilly commented 6 years ago

I'd like to second this. There appears to be very little documentation on the API for the workbox webpack plugin. Is there a page somewhere in the docs that provides details of the API? I've been so far going off this blog post:

https://zhirzh.github.io/2017/06/25/switching-to-workbox/

And also reading the source here:

https://github.com/GoogleChrome/workbox/blob/master/packages/workbox-build/src/index.js

Is there an API page on the workbox docs somewhere? An http://api.jquery.com/ for workbox is kind of what I'm after...

jeffposnick commented 6 years ago

Apologies for the amount of digging that's necessary.

@kaycebasques has just revamped the "Getting started with webpack" tutorial in this PR: https://github.com/google/WebFundamentals/pull/5238#issuecomment-340856323

It's not yet deployed, but I'd imagine that will go live on developers.google.com sometime today. It includes information on caching third-party URLs at runtime. (You can see a staged version of it at https://pr-5238-dot-web-central.appspot.com/web/tools/workbox/get-started/webpack)

That material is geared towards the v2 codebase, but our focus lately has been on a revamped webpack plugin as part of the Workbox v3 release. As part of that new interface, we'll release a new set of core documentation for various configuration options to supplement the "Getting started" guides.

I'm closing this issue given the new "Getting started" material for v2, and the fact that upcoming v3 webpack plugin documentation is already being tracked.

jeffposnick commented 6 years ago

https://developers.google.com/web/tools/workbox/get-started/webpack has now been updated.

johnnyreilly commented 6 years ago

That's awesome - thanks so much and I'll look out for it!