From da856dc853772715762f9b058fc1777a8e160511 Mon Sep 17 00:00:00 2001 From: NixReaper Date: Sun, 12 Jul 2026 09:38:16 -0500 Subject: [PATCH] Split Vue into a stable vendor chunk; make sourcemaps opt-out MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Pin `vue` to a named `vendor-vue` chunk (manualChunks) so its hash stays stable across app-code changes — returning users keep it cached across plugin releases instead of re-downloading ~31 kB gzip each update. Also replaces the misleadingly-named `_plugin-vue_export-helper` shared chunk. - Gate sourcemap emission on AURORA_SOURCEMAP (default on for the local hot-patch dev loop; the distribution build sets it to false). Cuts a from-scratch dist build's app/dist from ~1.7 MB to ~502 kB by dropping 27 .map files that ship no value to end users. - Refresh the stale header comment (was "one entry in this first slice"). Co-Authored-By: Claude Opus 4.8 --- app/vite.config.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) 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]',