-
Notifications
You must be signed in to change notification settings - Fork 45
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 it easier to render script tags with SRI data #45
Comments
Hi, many thanks for your suggestion. What you're after can be done without any changes to the plugin, here's one possible I realise this ☝️ is five lines of configuration more than in your approach (or ten, once you add proper error handling), and I like the idea of making it easier or less verbose in a future version. However, it would have to wait a few weeks because I'm not keen to add new features before 1.0.0 is out. I'm also not fully convinced that just dumping the data into a JSON file is the best way to go about this. It's certainly simple and generic, but it also feels a bit crude. There's probably other data to be shuffled from the Webpack build to the server, and so now it's the developer's responsibility to juggle a number of JSON files, pick a place for them to live etc. Obviously that's not the end of the world, and I might be overthinking this. I'd just like to have some confidence there's nothing better we can do. Are you aware of any consensus or discussion around this question (in the "Universal Webpack community", for lack of a better term)? Does the workaround help with your problem at hand, and we can let this simmer for a while? |
I wonder whether it would help if the SRI hashes were added to the result of |
Hi, thanks for all the feedback. I think the bottom line is that universal webpack is quite annoying. The pattern we're using is to render the index page with Express and thus we have to get some SRI data somehow. Maybe there is a better way. Thanks for the workaround. I guess it won't really be too different if
Do you mean so that I can just use the webpack-stats-plugin to dump a JSON file? Yeah, that seems like it would be helpful. |
Heh, nicely put.
Exactly... and that way we side-step a number of (small) issues. Let me talk to @sokra again to find out more about adding custom data to the stats. I'll keep this open for now as a reminder. Thanks again! |
Consider heading over to https://webpack.js.org/vote/ and voting for "Plugins for Stats - Allow plugins to modify stats and stat output". |
Voted! |
Coincidentally (with #74) this just got approved a few hours ago: webpack/webpack#6702 🎉 |
When not using the
html-webpack-plugin
, one needs to write a fair amount of custom code to render a script tag with proper SRI attributes for each asset.I'd like to propose a new
saveAs
option to make this easier. It would look like this:It would write a JSON file that gives you all the data you need to construct
script
tags:In any server view that writes an
index
page, one could then easily create a script tag like:Would you accept a patch for this?
BTW, this interface is what I was using in sri-stats-webpack but that one doesn't support webpack 2 so I have to migrate. The approached worked well enough for a universal React app.
The text was updated successfully, but these errors were encountered: