Skip to content

Commit

Permalink
Enable Subresource Integrity on Web
Browse files Browse the repository at this point in the history
  • Loading branch information
dani-garcia committed Jan 24, 2025
1 parent 3f05a5e commit db40776
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@
"webpack",
"webpack-cli",
"webpack-dev-server",
"webpack-node-externals"
"webpack-node-externals",
"webpack-subresource-integrity"
],
"description": "Platform owned dependencies",
"commitMessagePrefix": "[deps] Platform:",
Expand Down
9 changes: 9 additions & 0 deletions apps/web/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const HtmlWebpackInjector = require("html-webpack-injector");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const { SubresourceIntegrityPlugin } = require("webpack-subresource-integrity");
const webpack = require("webpack");

const config = require("./config.js");
Expand Down Expand Up @@ -85,6 +86,13 @@ const moduleRules = [
];

const plugins = [
new SubresourceIntegrityPlugin({
// Only enable SRI in production, otherwise it might break hot reloading.
// If for some reason you need to enable it in development, make sure to also set
// optimization.realContentHash to true in the webpack config.
enabled: NODE_ENV === "production",
hashFuncNames: ["sha512"],
}),
new HtmlWebpackPlugin({
template: "./src/index.html",
filename: "index.html",
Expand Down Expand Up @@ -382,6 +390,7 @@ const webpackConfig = {
filename: "[name].[contenthash].js",
path: path.resolve(__dirname, "build"),
clean: true,
crossOriginLoading: "anonymous",
},
module: {
noParse: /argon2(-simd)?\.wasm$/,
Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
"tabbable": "6.2.0",
"tldts": "6.1.74",
"utf-8-validate": "6.0.5",
"webpack-subresource-integrity": "^5.1.0",
"zone.js": "0.14.10",
"zxcvbn": "4.4.2"
},
Expand Down

0 comments on commit db40776

Please sign in to comment.