feat: add bundle analysis support

Add `webpack-bundle-analyzer` and a new `analyze` script to allow
visualizing bundle composition via `npm run analyze`.
This commit is contained in:
2026-07-08 15:16:12 +08:00
parent d95615f210
commit e0c3b8f4a0
3 changed files with 165 additions and 23 deletions
+26 -21
View File
@@ -1,7 +1,8 @@
import { defineConfig } from '@rsbuild/core';
import { pluginBabel } from '@rsbuild/plugin-babel';
import { pluginSolid } from '@rsbuild/plugin-solid';
import tailwindcss from '@tailwindcss/postcss';
import { defineConfig } from "@rsbuild/core";
import { pluginBabel } from "@rsbuild/plugin-babel";
import { pluginSolid } from "@rsbuild/plugin-solid";
import tailwindcss from "@tailwindcss/postcss";
import { BundleAnalyzerPlugin } from "webpack-bundle-analyzer";
export default defineConfig({
plugins: [
@@ -16,32 +17,36 @@ export default defineConfig({
plugins: [tailwindcss()],
},
},
rspack: {
module: {
rules: [
{
test: /\.md|\.yarn|\.csv$/,
exclude: /\.schema\.csv$/,
type: 'asset/source'
},
]
}
}
rspack: {
module: {
rules: [
{
test: /\.md|\.yarn|\.csv$/,
exclude: /\.schema\.csv$/,
type: "asset/source",
},
],
},
plugins: [
process.env.ANALYZE ? new BundleAnalyzerPlugin() : undefined,
].filter(Boolean),
},
},
html: {
template: './src/index.html',
template: "./src/index.html",
},
source: {
entry: {
index: './src/main.tsx',
index: "./src/main.tsx",
},
},
output: {
distPath: {
root: 'dist/web',
root: "dist/web",
},
copy: process.env.NODE_ENV === 'development' ? [
{ from: './content', to: 'content' }
] : [],
copy:
process.env.NODE_ENV === "development"
? [{ from: "./content", to: "content" }]
: [],
},
});