Skip to content

Commit

Permalink
fix: Output webpack-stats.json using webpack-stats-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
vio committed Sep 21, 2024
1 parent 174d1f5 commit daeed1b
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 daeed1b

Please sign in to comment.