Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ export default defineConfig(() => {
process.env.VITE_GIT_COMMIT_HASH = 'unknown'
}

// Unique per build: hashed filenames are content-based, so consecutive
// deploys reuse URLs for unchanged chunks. During a deploy transition the
// static host's SPA catch-all can answer a not-yet/no-longer-existing
// chunk URL with index.html, and the CDN edge then caches that HTML under
// the .js URL (s-maxage=86400) - poisoning the URL for a day. A build id
// in every filename makes each deploy's URLs fresh, so a poisoned entry
// is never requested again.
const buildId = Date.now().toString(36)

return {
plugins: [tailwindcss(), vue(), svgLoader()],
resolve: {
Expand All @@ -21,18 +30,21 @@ export default defineConfig(() => {
],
},
build: {
// mapbox-gl is the floor of the bundle (~1.7MB minified, ~470kB
// gzipped) and already lives in its own chunk via manualChunks
// below. Raise the warning so the build output isn't noisy; other
// chunks all sit comfortably below.
// maplibre-gl is the floor of the bundle (~1.5MB minified) and
// lives in its own chunk via manualChunks below. Raise the warning
// so the build output isn't noisy; other chunks all sit comfortably
// below.
chunkSizeWarningLimit: 1800,
rollupOptions: {
output: {
entryFileNames: `assets/[name]-[hash]-${buildId}.js`,
chunkFileNames: `assets/[name]-[hash]-${buildId}.js`,
assetFileNames: `assets/[name]-[hash]-${buildId}[extname]`,
// Vite 8 (rolldown) requires manualChunks as a function, not an
// object. Group third-party deps into named chunks to keep the
// initial bundle small.
manualChunks(id: string) {
if (id.includes('mapbox-gl')) return 'mapbox-gl'
if (id.includes('maplibre-gl')) return 'maplibre-gl'
if (id.includes('chart.js') || id.includes('chartjs-plugin-trendline')) return 'chart'
if (id.includes('vue-markdown-render')) return 'markdown'
},
Expand Down
Loading