diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index 6b358a45c..5d1ba50fc 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -19,7 +19,7 @@ jobs: - run: npm ci # Build and output bunle stats to webpack-stats.json - - run: yarn build --env TARGET=chrome --json webpack-stats.json + - run: yarn build --env TARGET=chrome # Upload webpack-stats.json to use on relative-ci.yaml workflow - name: Upload webpack stats artifact diff --git a/package-lock.json b/package-lock.json index 6abd7c6af..a6dc134e3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -102,6 +102,7 @@ "webextension-polyfill": "0.12.0", "webpack": "5.94.0", "webpack-cli": "5.1.4", + "webpack-stats-plugin": "^1.1.3", "ws": "^8.18.0" } }, @@ -27376,6 +27377,13 @@ "node": ">=10.13.0" } }, + "node_modules/webpack-stats-plugin": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/webpack-stats-plugin/-/webpack-stats-plugin-1.1.3.tgz", + "integrity": "sha512-yUKYyy+e0iF/w31QdfioRKY+h3jDBRpthexBOWGKda99iu2l/wxYsI/XqdlP5IU58/0KB9CsJZgWNAl+/MPkRw==", + "dev": true, + "license": "MIT" + }, "node_modules/webpack/node_modules/graceful-fs": { "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", diff --git a/package.json b/package.json index 808a3c222..10859e693 100755 --- a/package.json +++ b/package.json @@ -131,6 +131,7 @@ "webextension-polyfill": "0.12.0", "webpack": "5.94.0", "webpack-cli": "5.1.4", + "webpack-stats-plugin": "1.1.3", "ws": "^8.18.0" } } diff --git a/webpack.config.js b/webpack.config.js index 5ae0a479d..683bc2d25 100755 --- a/webpack.config.js +++ b/webpack.config.js @@ -3,6 +3,7 @@ import url from "url"; import CopyPlugin from "copy-webpack-plugin"; import TerserPlugin from "terser-webpack-plugin"; import WebExtPlugin from "web-ext-plugin"; +import { StatsWriterPlugin } from "webpack-stats-plugin"; import webpack from "webpack"; import packageJson from "./package.json" with { type: "json" }; @@ -40,6 +41,19 @@ export default /** @returns {import("webpack").Configuration} */ (env) => { }), ]; + if (env.NODE_ENV === "production") { + plugins.push( + new StatsWriterPlugin({ + filename: "../webpack-stats.json", + stats: { + assets: true, + chunks: true, + modules: true, + }, + }) + ); + } + if (IS_EXTENSION) { plugins.push( new CopyPlugin({