Split Vue into a stable vendor chunk; make sourcemaps opt-out
- 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 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
1c8c351654
commit
da856dc853
+17
-4
@@ -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]',
|
||||
|
||||
Reference in New Issue
Block a user