Skip to content

Commit

Permalink
fix: Output webpack-stats.json using webpack-stats-plugin (#1529)
Browse files Browse the repository at this point in the history
  • Loading branch information
vio authored Sep 23, 2024
1 parent 174d1f5 commit 5a75c41
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 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 @@ -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"
}
}
14 changes: 14 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" };

Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit 5a75c41

Please sign in to comment.