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
Support importWorkboxFrom: 'local' in the InjectManifest webpack plugin #1290
Conversation
@@ -80,10 +80,13 @@ describe(`[workbox-webpack-plugin] GenerateSW (End to End)`, function() { | |||
const compiler = webpack(config); | |||
compiler.run((webpackError) => { | |||
if (webpackError) { | |||
expect(webpackError.message.includes('importWorkboxFrom')); | |||
done(); | |||
if (webpackError.message.includes('importWorkboxFrom')) { |
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.
FYI, in the course of writing this PR, I discovered that this test pattern wasn't actually working as it was initially implemented: it should have been expect(webpackError.message.includes('importWorkboxFrom')).to.be.true
, although that would then cause an unhandled promise rejection rather than a clean error to report back to mocha
.
I took the opportunity to clean up this test along with the corresponding test in the inject-manifest.js
suite so that it properly detects the failure and reports it using the done()
callback.
const postInjectionSWString = `importScripts(${importScriptsString}); | ||
const setConfigString = modulePathPrefix | ||
? `workbox.setConfig({modulePathPrefix: ` + | ||
`${JSON.stringify(modulePathPrefix)}});` |
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.
Do you think JSON.stringify
is necessary?
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.
It's safer than wrapping the value in either "..."
or '...'
, just on the off chance modulePathPrefix
contains any quote characters. (Not that it should, but still.)
JSON.stringify()
is guaranteed to return a properly escaped string.
}); | ||
}); | ||
|
||
it(`should support setting importWorkboxFrom to 'local'`, function(done) { |
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.
It'd be cool to include a test where Webpack publicPath
is specified
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.
Done.
PR-Bot Size PluginChanged File Sizes
New FilesNo new files have been added. All File SizesView Table
Workbox Aggregate Size Plugin☠️ WARNING ☠️We are using 154% of our max size budget. Total Size: 22.52KB Gzipped: 9.01KB |
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 looks good to me.
After testing out What do you guys think of a different implementation on copying on disk versus Webpack compilation? |
Rather than discussing this on a merged PR, I created #1338 |
R: @gauntface
CC: @raejin
Fixes #1260
This adds
importWorkboxFrom: 'local'
support to theInjectManifest
webpack plugin. (It's still not supported ininjectManifest
mode of theworkbox-build
orworkbox-cli
.)Assuming this PR is merged, I'll need to update https://github.com/google/WebFundamentals to reflect the new config.