Description
The CspHtmlWebpackPlugin generates incorrect hashes, causing issues when trying to use the generated CSP.
I have created a GitHub repository to reproduce the issue and deployed the site for reference:
My observations
If I copy the content of the <style> or <script> tags from the generated index.html into an online CSP hash generator, I get different hash values. When I manually replace the generated hashes in index.html with these correct values, my site works as expected without CSP violations.
I could not prove it but maybe the issue is related to #111
What type of issue is this? (place an x in one of the [ ])
Requirements (place an x in each of the [ ])
Bug Report
Reproducible in:
slackhq/csp-html-webpack-plugin version: 5.1.0
node version: 22.10.0
OS version(s): macOS Sequoia 15.01, Ubuntu 24.04
Steps to reproduce:
- Clone the reproduction repository:
git clone https://github.com/warnyul/bvarga.dev.git
- Install dependencies:
npm install
- Build the project:
npm run build
- Open
index.html in dist folder using Safari or Google Chrome.
Expected result:
The hashes generated by the CspHtmlWebpackPlugin should correctly match the content of the built files.
Actual result:
The hashes generated by the plugin do not match the content of the files, causing CSP violations in the browser when accessing the deployed site. Manually generated hashes work correctly when applied.
Description
The
CspHtmlWebpackPlugingenerates incorrect hashes, causing issues when trying to use the generated CSP.I have created a GitHub repository to reproduce the issue and deployed the site for reference:
My observations
If I copy the content of the
<style>or<script>tags from the generatedindex.htmlinto an online CSP hash generator, I get different hash values. When I manually replace the generated hashes inindex.htmlwith these correct values, my site works as expected without CSP violations.I could not prove it but maybe the issue is related to #111
What type of issue is this? (place an
xin one of the[ ])Requirements (place an
xin each of the[ ])Bug Report
Reproducible in:
slackhq/csp-html-webpack-plugin version: 5.1.0
node version: 22.10.0
OS version(s): macOS Sequoia 15.01, Ubuntu 24.04
Steps to reproduce:
git clone https://github.com/warnyul/bvarga.dev.gitnpm installnpm run buildindex.htmlindistfolder using Safari or Google Chrome.Expected result:
The hashes generated by the
CspHtmlWebpackPluginshould correctly match the content of the built files.Actual result:
The hashes generated by the plugin do not match the content of the files, causing CSP violations in the browser when accessing the deployed site. Manually generated hashes work correctly when applied.