Skip to content

Commit 5a75c41

Browse files
authored
fix: Output webpack-stats.json using webpack-stats-plugin (#1529)
1 parent 174d1f5 commit 5a75c41

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

.github/workflows/build-pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- run: npm ci
2020

2121
# Build and output bunle stats to webpack-stats.json
22-
- run: yarn build --env TARGET=chrome --json webpack-stats.json
22+
- run: yarn build --env TARGET=chrome
2323

2424
# Upload webpack-stats.json to use on relative-ci.yaml workflow
2525
- name: Upload webpack stats artifact

package-lock.json

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
"webextension-polyfill": "0.12.0",
132132
"webpack": "5.94.0",
133133
"webpack-cli": "5.1.4",
134+
"webpack-stats-plugin": "1.1.3",
134135
"ws": "^8.18.0"
135136
}
136137
}

webpack.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import url from "url";
33
import CopyPlugin from "copy-webpack-plugin";
44
import TerserPlugin from "terser-webpack-plugin";
55
import WebExtPlugin from "web-ext-plugin";
6+
import { StatsWriterPlugin } from "webpack-stats-plugin";
67
import webpack from "webpack";
78
import packageJson from "./package.json" with { type: "json" };
89

@@ -40,6 +41,19 @@ export default /** @returns {import("webpack").Configuration} */ (env) => {
4041
}),
4142
];
4243

44+
if (env.NODE_ENV === "production") {
45+
plugins.push(
46+
new StatsWriterPlugin({
47+
filename: "../webpack-stats.json",
48+
stats: {
49+
assets: true,
50+
chunks: true,
51+
modules: true,
52+
},
53+
})
54+
);
55+
}
56+
4357
if (IS_EXTENSION) {
4458
plugins.push(
4559
new CopyPlugin({

0 commit comments

Comments
 (0)