diff --git a/app/vite.config.js b/app/vite.config.js index cbb3d58..a90463b 100644 --- a/app/vite.config.js +++ b/app/vite.config.js @@ -2,9 +2,20 @@ import { defineConfig } from 'vite'; import vue from '@vitejs/plugin-vue'; import { fileURLToPath, URL } from 'node:url'; -// Deliberately simple: one entry in this first slice (dashboard). Add more -// entries here as additional pages get rebuilt — same flat pattern each -// time, no shared scoping/theme-remap layer to keep in sync across files. +// Multi-entry build: one entry per admin screen (see rollupOptions.input). +// Each is enqueued as its own ES module by admin/src/Utility/Assets.php, +// which also walks the manifest's `imports` chain for shared-chunk CSS. +// Rollup automatically splits code shared by 2+ entries into its own chunk; +// `vue` is pinned to a named `vendor-vue` chunk below so its hash stays +// stable across app-code changes (returning users keep it cached across +// plugin updates instead of re-downloading it every release). +// +// Sourcemaps are on by default for local debugging (the dev loop hot-patches +// app/dist into a LocalWP install). The distribution build sets +// AURORA_SOURCEMAP=false so the shipped zip doesn't carry ~1.2 MB of .map +// files that are useless to end users. +const emitSourcemaps = process.env.AURORA_SOURCEMAP !== 'false'; + export default defineConfig({ root: fileURLToPath(new URL('./src', import.meta.url)), plugins: [vue()], @@ -16,7 +27,7 @@ export default defineConfig({ build: { outDir: fileURLToPath(new URL('./dist', import.meta.url)), emptyOutDir: true, - sourcemap: true, + sourcemap: emitSourcemaps, manifest: true, rollupOptions: { input: { @@ -43,6 +54,8 @@ export default defineConfig({ 'bug-report': fileURLToPath(new URL('./src/entries/bug-report.js', import.meta.url)), }, output: { + // Keep Vue in its own long-lived vendor chunk (see header note). + manualChunks: { 'vendor-vue': ['vue'] }, entryFileNames: '[name].[hash].js', chunkFileNames: 'assets/[name].[hash].js', assetFileNames: 'assets/[name].[hash][extname]',