Experiment: migrate web build to vite-plus 1.3.0

- vp migrate rewrote scripts (vite build -> vp build), aliased vite to
  @voidzero-dev/vite-plus-core 1.3.0 with an overrides pin, and switched
  the config import to vite-plus.
- Manual one-line fix migrate missed: minify "esbuild" -> true (Vite 8
  dropped bundled esbuild; oxc minifier is the replacement).
- Widened cleanStaleChunks sweep from .js/.js.map to .css/.mjs too:
  Rolldown renames emitted css chunks, and two stale vite-7-era css
  files (annotation_layer_builder, text_layer_builder) survived the
  old js-only regex.
- Verified: both custom plugins survive; prod/dev/watch builds OK;
  two consecutive builds idempotent at 289 files; vendor/pdfjs assets
  byte-identical; entry names (main.js/reader.js) unchanged.
This commit is contained in:
John O'Keefe committed 2026-10-21 09:27:59 -04:00
1 parent dd4cf1235c
commit 8aeecaa0ef
2 files changed
+13 -10

No files matched your search

+8 -4
View File
@@ -5,9 +5,9 @@
"scripts": {
"build:css": "tailwindcss -i ./web/static/input.css -o ./web/static/style.css --watch",
"build:css:prod": "tailwindcss -i ./web/static/input.css -o ./web/static/style.css --minify",
"build:ts": "cp node_modules/htmx.org/dist/htmx.min.js web/static/htmx.min.js && vite build",
"build:ts:dev": "cp node_modules/htmx.org/dist/htmx.min.js web/static/htmx.min.js && vite build --mode development",
"build:ts:watch": "cp node_modules/htmx.org/dist/htmx.min.js web/static/htmx.min.js && vite build --watch",
"build:ts": "cp node_modules/htmx.org/dist/htmx.min.js web/static/htmx.min.js && vp build",
"build:ts:dev": "cp node_modules/htmx.org/dist/htmx.min.js web/static/htmx.min.js && vp build --mode development",
"build:ts:watch": "cp node_modules/htmx.org/dist/htmx.min.js web/static/htmx.min.js && vp build --watch",
"build": "npm run build:ts && npm run build:css:prod",
"dev": "npm run build:ts:dev && npm run build:css"
},
@@ -34,6 +34,10 @@
"playwright": "^1.64.1",
"tailwindcss": "^3.4.19",
"typescript": "^5.9.3",
"vite": "^7.3.1"
"vite": "npm:@voidzero-dev/vite-plus-core@1.3.0",
"vite-plus": "1.3.0"
},
"overrides": {
"vite": "npm:@voidzero-dev/vite-plus-core@1.3.0"
}
}
+5 -6
View File
@@ -1,4 +1,4 @@
import { defineConfig } from "vite";
import { defineConfig } from "vite-plus";
import { cpSync, mkdirSync, readdirSync, rmSync } from "node:fs";
import { join } from "node:path";
@@ -6,8 +6,7 @@ const pdfjsAssets = () => ({
name: "pdfjs-assets",
closeBundle() {
const outDir = "web/static/vendor/pdfjs";
const srcDir =
"node_modules/@bookhoard/foliate-js/vendor/pdfjs";
const srcDir = "node_modules/@bookhoard/foliate-js/vendor/pdfjs";
mkdirSync(outDir, { recursive: true });
cpSync(join(srcDir, "standard_fonts"), join(outDir, "standard_fonts"), {
recursive: true,
@@ -19,7 +18,7 @@ const pdfjsAssets = () => ({
// emptyOutDir must stay false (web/static also holds tracked assets),
// so hashed chunks from previous builds would otherwise accumulate
// forever and leak into Docker images via the build context. Remove
// any *-<hash>.js(.map) that this build did not produce.
// any *-<hash>.js/.css/.mjs(.map) that this build did not produce.
const cleanStaleChunks = () => {
const produced = new Set<string>();
return {
@@ -29,7 +28,7 @@ const cleanStaleChunks = () => {
},
closeBundle() {
const outDir = "web/static";
const chunkRe = /-[A-Za-z0-9_-]{8}\.js(\.map)?$/;
const chunkRe = /-[A-Za-z0-9_-]{8}\.(js|css|mjs)(\.map)?$/;
for (const f of readdirSync(outDir)) {
if (chunkRe.test(f) && !produced.has(f)) {
rmSync(join(outDir, f));
@@ -63,6 +62,6 @@ export default defineConfig({
},
target: "esnext",
sourcemap: true,
minify: "esbuild",
minify: true,
},
});