You can compare and analyze the webpack bundle changes on your local environment using the bundle-stats cli. (bundle-stats is the open-source tool used by RelativeCI to analyze webpack stats and generate reports.)
To generate webpack stats, you can use the webpack CLI method or a plugin to write the stats file (Learn how to output webpack stats here). For the CLI method used below, the following webpack stats options are needed:
module.exports = { stats: { assets: true, chunks: true, modules: true }}Step 1: Generate baseline webpack stats
# Switch to default branchgit checkout main
# Generate webpack statsnpx webpack --mode production --json main.jsonYou can use an existing RelativeCI job data source as a baseline or change. To download the webpack stats JSON, navigate to a job page, click on the job options menu and select Job info. On the job info dialog you can copy or download the webpack stats JSON data.
Step 2: Generate change webpack stats
# Switch to custom branch/taggit checkout feature-branch
# Generate webpack statsnpx webpack --mode production --json feature-branch.jsonStep 3: Compare and analyze webpack stats
npx bundle-stats feature-branch.json main.json ✔ Read Webpack stats files ↓ Read baseline data [skipped] → Missing baseline stats, see "--baseline" option. ↓ Write baseline data [skipped] → Not a baseline job (see --baseline). ✔ Process data ✔ Generate reports ✔ Save reports
Artifacts:- dist/bundle-stats.html- If there are
package.jsonupdates between the branches, runnpm install/yarn/pnpmbefore webpack stats generation. bundle-stats.htmlis a standalone HTML file, you can upload it to any static hosting for sharing.