Add vite-bundle-analyzer for bundle size checking (#1679)

* Add vite-bundle-analyzer for bundle size checking

* make bundle-analyzer optional
This commit is contained in:
Israr
2026-04-28 22:33:22 +12:00
committed by GitHub
parent f702191d68
commit 7e88b62f6c
4 changed files with 57 additions and 14 deletions
+12
View File
@@ -12,3 +12,15 @@ npm run build
```
See `package.json` for other useful scripts.
## Bundle Analyzer
To generate a bundle analysis report, run:
On Windows PowerShell:
$env:ANALYZE=1; npm run build
On Linux/macOS:
ANALYZE=1 npm run build
This will include the analyzer in the build and output a report.
+18 -14
View File
@@ -1,6 +1,7 @@
// vite.config.js
import {resolve} from 'path'
import {defineConfig} from 'vite'
import viteBundleAnalyzer from 'vite-bundle-analyzer';
import {viteStaticCopy} from 'vite-plugin-static-copy'
export default defineConfig({
@@ -20,20 +21,23 @@ export default defineConfig({
'Cross-Origin-Opener-Policy': 'same-origin',
},
},
plugins: [viteStaticCopy({
targets: [
// If type declaration files are missing, the web editor can't
// load them, and type validation won't work for our core modules.
{
src: './node_modules/manifold-3d/dist/manifoldCAD.d.ts',
dest: './', // Targets are relative to 'dist'.
},
{
src: './node_modules/manifold-3d/dist/manifoldCADGlobals.d.ts',
dest: './',
}
],
})],
plugins: [
viteStaticCopy({
targets: [
// If type declaration files are missing, the web editor can't
// load them, and type validation won't work for our core modules.
{
src: './node_modules/manifold-3d/dist/manifoldCAD.d.ts',
dest: './', // Targets are relative to 'dist'.
},
{
src: './node_modules/manifold-3d/dist/manifoldCADGlobals.d.ts',
dest: './',
}
],
}),
process.env.ANALYZE ? viteBundleAnalyzer() : null
].filter(Boolean),
resolve: {
alias: {
path: resolve(
+22
View File
@@ -0,0 +1,22 @@
{
"name": "Manifold",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"devDependencies": {
"vite-bundle-analyzer": "^1.3.7"
}
},
"node_modules/vite-bundle-analyzer": {
"version": "1.3.7",
"resolved": "https://registry.npmjs.org/vite-bundle-analyzer/-/vite-bundle-analyzer-1.3.7.tgz",
"integrity": "sha512-dYlW6iM0Gq7+uSEfXytDC+UjruUMgEKhXwQUbw4cJUgHA6FdEhpLgIrL5OZEyabrzVen0mZyfOSESyZ7nGyT8g==",
"dev": true,
"license": "MIT",
"bin": {
"analyze": "dist/bin.js"
}
}
}
}
+5
View File
@@ -0,0 +1,5 @@
{
"devDependencies": {
"vite-bundle-analyzer": "^1.3.7"
}
}