assets-webpack-plugin: integrity configuration not working
Describe the bug
According to the docs, setting integrity: true should generate jsIntegrity in the output. But in my case, jsIntegrity is not generated.
To Reproduce I have made a minimal reproducible example. Steps to reproduce the behavior:
- Clone https://github.com/niyoko/assets-webpack-plugin-issue
- Run
npm install - Run
npm run build - View
dist/webpack-assets.json
Expected behavior
In dist/webpack-assets.json should includes integrity hash for the outputed JS.
Webpack Config
const path = require('path');
const AssetsPlugin = require('assets-webpack-plugin');
const SriPlugin = require('webpack-subresource-integrity');
module.exports = {
mode: 'production',
output: {
path: path.join(__dirname, 'dist'),
filename: '[name]-bundle-[contenthash].js',
publicPath: '/js/',
crossOriginLoading: 'anonymous',
},
plugins: [
new AssetsPlugin({
path: path.join(__dirname, 'dist'),
prettyPrint: true,
integrity: true,
}),
new SriPlugin({
hashFuncNames: ['sha256', 'sha384'],
enabled: true,
}),
],
};
Desktop (please complete the following information):
- OS: ArchLinux 5.4.83-1-lts
- Node version: 14.15.1
- Plugin version: 7.0.0
Additional context
- webpack-subresource-integrity version: 1.5.2
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 24 (13 by maintainers)
Commits related to this issue
- test: integration test for SriPlugin To allow further refactoring/fixing of #327 since current solution breaks #404 and symfony/webpack-encore#969 Resolves: #392 #327 — committed to Den-dp/assets-webpack-plugin by Den-dp 3 years ago
- test: integration test for SriPlugin To allow further refactoring/fixing of #327 since current solution breaks #404 and symfony/webpack-encore#969 Resolves: #392 #327 — committed to Den-dp/assets-webpack-plugin by Den-dp 3 years ago
Should be fixed in
v7.1.0, let me know otherwise. Thanks again @lebleb!Content and Map of this Source is no longer available
@markcampbell24 , Webpack 5 replaces the Sources in Compilation.assets with SizeOnlySource variants to reduce memory usage before afterEmit hook call. https://webpack.js.org/blog/2020-10-10-webpack-5-release/#sizeonlysource-after-emit
Is it not possible to update the hooks part for only Webpack 5?
from:
to:
@markcampbell24 would you mind sharing your config? Going to see if I can figure this out later today.