Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make webpack path and filename options more customizable #1403

Merged
merged 2 commits into from
Mar 29, 2018

Conversation

jeffposnick
Copy link
Contributor

@jeffposnick jeffposnick commented Mar 28, 2018

R: @addyosmani @gauntface
CC: @raejin

Fixes #1285

This adds the following to both the InjectManifest and GenerateSW webpack plugins:

  • An optional precacheManifestFilename parameter, defaulting to 'precache-manifest.[manifestHash].js' (i.e. the current behavior). It can be used to customize the precache manifest name. If the string '[manifestHash]' isn't included in your custom name, that's treated as a webpack compilation error.

  • An optional importsDirectory parameter, defaulting to '' (i.e. the current behavior). It is treated as a subdirectory of output.path. When set, the precache manifest is written to this directory, and if importWorkboxFrom: 'local', the local Workbox libraries are written there as well.

  • Automatic adjustments to the URLs used in importScripts() to account for both of these potential customizations.

  • When importWorkboxFrom: 'local' and output.publicPath is configured, the output.publicPath value will be prepended to the modulePathPrefix used to determine where the Workbox libraries are dynamically loaded from. This amounts to a change in the previous behavior, but based on developer expectation, the previous behavior was considered a bug.

There needs to be a corresponding update to the WebFundamentals docs once this is merged.

excludeChunks: [],
importScripts: [],
importWorkboxFrom: 'cdn',
this.config = Object.assign(getDefaultConfig(), {
swDest: 'service-worker.js',
Copy link

@gauntface gauntface Mar 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment to both plugins calling out why this is seperate.

@workbox-pr-bot
Copy link
Collaborator

PR-Bot Size Plugin

Changed File Sizes

File Before After Change GZipped
packages/workbox-build/build/index.js 2.52 KB 4.03 KB +60% 1.57 KB ☠️
packages/workbox-core/build/workbox-core.prod.js 6.47 KB 6.55 KB +1% 2.64 KB
packages/workbox-precaching/build/workbox-precaching.prod.js 5.66 KB 5.74 KB +1% 2.17 KB
packages/workbox-webpack-plugin/build/generate-sw.js 7.38 KB 8.04 KB +9% 2.57 KB
packages/workbox-webpack-plugin/build/inject-manifest.js 8.96 KB 9.60 KB +7% 3.05 KB

New Files

No new files have been added.

All File Sizes

View Table
File Before After Change GZipped
packages/workbox-background-sync/build/workbox-background-sync.prod.js 3.51 KB 3.51 KB 0% 1.45 KB
packages/workbox-broadcast-cache-update/build/workbox-broadcast-cache-update.prod.js 1.12 KB 1.12 KB 0% 584 B
packages/workbox-build/build/_types.js 41 B 41 B 0% 61 B
packages/workbox-build/build/index.js 2.52 KB 4.03 KB +60% 1.57 KB ☠️
packages/workbox-cache-expiration/build/workbox-cache-expiration.prod.js 3.40 KB 3.40 KB 0% 1.25 KB
packages/workbox-cacheable-response/build/workbox-cacheable-response.prod.js 587 B 587 B 0% 345 B
packages/workbox-cli/build/app.js 6.50 KB 6.50 KB 0% 2.16 KB
packages/workbox-cli/build/bin.js 2.32 KB 2.32 KB 0% 1.03 KB
packages/workbox-core/build/workbox-core.prod.js 6.47 KB 6.55 KB +1% 2.64 KB
packages/workbox-google-analytics/build/workbox-google-analytics.prod.js 2.13 KB 2.13 KB 0% 1.05 KB
packages/workbox-precaching/build/workbox-precaching.prod.js 5.66 KB 5.74 KB +1% 2.17 KB
packages/workbox-range-requests/build/workbox-range-requests.prod.js 1.64 KB 1.64 KB 0% 802 B
packages/workbox-routing/build/workbox-routing.prod.js 2.77 KB 2.77 KB 0% 1.25 KB
packages/workbox-strategies/build/workbox-strategies.prod.js 3.37 KB 3.37 KB 0% 1.03 KB
packages/workbox-sw/build/workbox-sw.js 1.45 KB 1.45 KB 0% 788 B
packages/workbox-webpack-plugin/build/generate-sw.js 7.38 KB 8.04 KB +9% 2.57 KB
packages/workbox-webpack-plugin/build/index.js 742 B 742 B 0% 470 B
packages/workbox-webpack-plugin/build/inject-manifest.js 8.96 KB 9.60 KB +7% 3.05 KB

Workbox Aggregate Size Plugin

☠️ WARNING ☠️

We are using 159% of our max size budget.

Total Size: 23.3KB
Percentage of Size Used: 159%

Gzipped: 9.25KB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

InjectManifest Plugin – Set manifest dest
3 participants