-
Notifications
You must be signed in to change notification settings - Fork 828
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
Add in asset filename filtering via {test, include, exclude} #1149
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,9 @@ | |
"json-stable-stringify": "^1.0.1", | ||
"workbox-build": "^3.0.0-alpha.3" | ||
}, | ||
"peerDependencies": { | ||
"webpack": "^2.0.0 || ^3.0.0" | ||
}, | ||
"author": "Will Farley <[email protected]> (http://www.willfarley.org/)", | ||
"license": "Apache-2.0", | ||
"repository": "googlechrome/workbox", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ | |
limitations under the License. | ||
*/ | ||
|
||
const ModuleFilenameHelpers = require('webpack/lib/ModuleFilenameHelpers'); | ||
|
||
const getAssetHash = require('./get-asset-hash'); | ||
const resolveWebpackUrl = require('./resolve-webpack-url'); | ||
|
||
|
@@ -177,6 +179,13 @@ function getManifestEntriesFromCompilation(compilation, config) { | |
|
||
const manifestEntries = []; | ||
for (const [file, metadata] of Object.entries(filteredAssetMetadata)) { | ||
// Filter based on test/include/exclude options set in the webpack config. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you just add a comment on the end of this sentence along the lines "This matches behaviour of uglifyJS". Copying and pasting links is O.T.T. to get the gist of the point your are getting across. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would also be worth calling out that we can take advantage of webpacks built in filtering (which for me is a better reason for this approach over something uglify does). |
||
// See https://github.com/GoogleChrome/workbox/issues/935#issue-267021143 and | ||
// https://github.com/webpack-contrib/uglifyjs-webpack-plugin/blob/025262284c86196d0a4c4fe71e186132579629ec/src/index.js | ||
if (!ModuleFilenameHelpers.matchObject(config, file)) { | ||
continue; | ||
} | ||
|
||
const publicUrl = resolveWebpackUrl(publicPath, file); | ||
const manifestEntry = getEntry(knownHashes, publicUrl, metadata.hash); | ||
manifestEntries.push(manifestEntry); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems unusual to me, is it stipulating that workbox only works with Webpack 2 and 3 (i.e. not 4)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am following UglifyJS's lead here in limited the acceptable peer dependency: https://github.com/webpack-contrib/uglifyjs-webpack-plugin/blob/025262284c86196d0a4c4fe71e186132579629ec/package.json#L75-L77
(My understanding is that webpack 4 changes the plugin architecture anyway, so I think we should track that separately: #1151)