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

Add support for SRI like in Webpack-Html-Plugin #10

Closed
swernerx opened this issue Jun 22, 2017 · 2 comments
Closed

Add support for SRI like in Webpack-Html-Plugin #10

swernerx opened this issue Jun 22, 2017 · 2 comments

Comments

@swernerx
Copy link
Contributor

It would be nice when the plugin would be able to use the integrity information added to assets by the SRI plugin: https://www.npmjs.com/package/webpack-subresource-integrity.

This section might be helpful for implementation:
https://www.npmjs.com/package/webpack-subresource-integrity#without-htmlwebpackplugin

With this is place it would be safe to push all these bundles onto a CDN as the browser checks whether the SRI checksums are matching and the correct files are being delivered.

@faceyspacey
Copy link
Owner

faceyspacey commented Jun 22, 2017

That doesn't seem too hard. I don't use it. It's probably best in userland. It seems if you just have an array of chunkNames (which I can return in the final return as a minor change), you can use just the returned stylesheets and scripts and construct the <script /> and <link /> strings yourself by using each chunk name to get the integrity value from stats.compilation.assets[mainAssetName].integrity.

I.e. to create something like this:

<link
     rel="stylesheet"
     href="<%= htmlWebpackPlugin.files.css[index] %>"
     integrity="<%= htmlWebpackPlugin.files.cssIntegrity[index] %>"
     crossorigin="<%= webpackConfig.output.crossOriginLoading %>"
  />

And of course the crossOriginLoading it seems you will already know.

If you're using Webpack "magic comments" (or require.ensure with the chunkName argument) and React Universal Component you will in fact already have the chunk names for all dynamic chunks, and you should know the chunk names for named entry points.

Perhaps that solves your problem for now. You can use the flushFiles Low-level API to achieve this.

@faceyspacey
Copy link
Owner

I'm just gonna close this cuz I'm cleaning house and likely won't be able to prioritize it.

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

No branches or pull requests

2 participants