chore(11-01): add ANALYZE=true opt-in for rollup-plugin-visualizer in vite.config.js

- Wrapped config in async defineConfig factory so visualizer can be dynamically
  imported only when ANALYZE=true; normal builds incur zero overhead
- Added frontend/stats.html to .gitignore (ephemeral artifact; canonical copy
  lives in .planning/perf/)
This commit is contained in:
curo1305
2026-06-16 21:04:54 +02:00
parent 41d136fa1f
commit 0fb2a53a4f
2 changed files with 32 additions and 15 deletions
+1
View File
@@ -5,4 +5,5 @@ backend/data/
frontend/node_modules/ frontend/node_modules/
frontend/dist/ frontend/dist/
frontend/package-lock.json frontend/package-lock.json
frontend/stats.html
screenshots/ screenshots/
+31 -15
View File
@@ -1,20 +1,36 @@
import { defineConfig } from 'vite' import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue' import vue from '@vitejs/plugin-vue'
export default defineConfig({ // Bundle analyzer: only active when ANALYZE=true is set in the environment.
plugins: [vue()], // Usage: ANALYZE=true npm run build
build: { // Output: stats.html in the project root (committed to .planning/perf/ manually).
// top-level await in main.js requires esnext target function conditionalAnalyzer(env) {
target: 'esnext', if (env.ANALYZE !== 'true') return null
}, // Dynamic import so the package is never executed during normal builds.
server: { return import('rollup-plugin-visualizer').then(({ visualizer }) =>
host: '0.0.0.0', visualizer({ open: false, filename: 'stats.html', gzipSize: true })
port: 5173, )
proxy: { }
'/api': {
target: 'http://backend:8000', export default defineConfig(async ({ mode }) => {
changeOrigin: true, const env = loadEnv(mode, process.cwd(), '')
const analyzerPlugin = await conditionalAnalyzer(env)
return {
plugins: [vue(), ...(analyzerPlugin ? [analyzerPlugin] : [])],
build: {
// top-level await in main.js requires esnext target
target: 'esnext',
},
server: {
host: '0.0.0.0',
port: 5173,
proxy: {
'/api': {
target: 'http://backend:8000',
changeOrigin: true,
},
}, },
}, },
}, }
}) })