chore(deps): align frontend toolchain on vite 7 and split admin bundle
Upgrade admin-web and desktop-client onto Vite 7 / Vitest 4 with the matching @vitejs/plugin-vue 6 and electron-vite 5, and introduce manualChunks plus gzip/brotli compression so the admin bundle ships in smaller, route-aware pieces. ANALYZE=true emits a treemap via rollup-plugin-visualizer; the generated stats.html is gitignored. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -19,3 +19,4 @@ apps/*/firefox-mv*/
|
|||||||
.playwright-cli/*
|
.playwright-cli/*
|
||||||
*.log
|
*.log
|
||||||
*.tmp
|
*.tmp
|
||||||
|
apps/*/stats.html
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "vue-tsc --noEmit && vite build",
|
"build": "vue-tsc --noEmit && vite build",
|
||||||
|
"build:analyze": "vue-tsc --noEmit && ANALYZE=true vite build",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"typecheck": "vue-tsc --noEmit"
|
"typecheck": "vue-tsc --noEmit"
|
||||||
},
|
},
|
||||||
@@ -18,13 +19,13 @@
|
|||||||
"@milkdown/kit": "^7.20.0",
|
"@milkdown/kit": "^7.20.0",
|
||||||
"@milkdown/theme-nord": "^7.20.0",
|
"@milkdown/theme-nord": "^7.20.0",
|
||||||
"@milkdown/vue": "^7.20.0",
|
"@milkdown/vue": "^7.20.0",
|
||||||
"nanoid": "^5.1.7",
|
|
||||||
"@tanstack/vue-query": "^5.96.0",
|
"@tanstack/vue-query": "^5.96.0",
|
||||||
"@vueuse/core": "^14.2.1",
|
"@vueuse/core": "^14.2.1",
|
||||||
"ant-design-vue": "^4.2.6",
|
"ant-design-vue": "^4.2.6",
|
||||||
"dayjs": "^1.11.20",
|
"dayjs": "^1.11.20",
|
||||||
"dompurify": "^3.3.3",
|
"dompurify": "^3.3.3",
|
||||||
"markdown-it": "^14.1.1",
|
"markdown-it": "^14.1.1",
|
||||||
|
"nanoid": "^5.1.7",
|
||||||
"pinia": "^3.0.4",
|
"pinia": "^3.0.4",
|
||||||
"vue": "^3.5.31",
|
"vue": "^3.5.31",
|
||||||
"vue-i18n": "^10.0.5",
|
"vue-i18n": "^10.0.5",
|
||||||
@@ -35,8 +36,10 @@
|
|||||||
"@types/markdown-it": "^14.1.2",
|
"@types/markdown-it": "^14.1.2",
|
||||||
"@types/node": "^24.0.0",
|
"@types/node": "^24.0.0",
|
||||||
"@vitejs/plugin-vue": "^6.0.5",
|
"@vitejs/plugin-vue": "^6.0.5",
|
||||||
|
"rollup-plugin-visualizer": "^7.0.1",
|
||||||
"typescript": "^5.9.3",
|
"typescript": "^5.9.3",
|
||||||
"vite": "^8.0.3",
|
"vite": "^7.3.2",
|
||||||
|
"vite-plugin-compression2": "^2.5.3",
|
||||||
"vue-tsc": "^3.2.6"
|
"vue-tsc": "^3.2.6"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+126
-11
@@ -1,22 +1,47 @@
|
|||||||
|
import { fileURLToPath, URL } from "node:url";
|
||||||
|
|
||||||
import vue from "@vitejs/plugin-vue";
|
import vue from "@vitejs/plugin-vue";
|
||||||
import { defineConfig, loadEnv } from "vite";
|
import { visualizer } from "rollup-plugin-visualizer";
|
||||||
|
import { defineConfig, loadEnv, type PluginOption } from "vite";
|
||||||
|
import { compression } from "vite-plugin-compression2";
|
||||||
|
|
||||||
|
const r = (path: string) => fileURLToPath(new URL(path, import.meta.url));
|
||||||
|
|
||||||
export default defineConfig(({ mode }) => {
|
export default defineConfig(({ mode }) => {
|
||||||
const env = loadEnv(mode, ".", "");
|
const env = loadEnv(mode, ".", "");
|
||||||
|
const isProd = mode === "production";
|
||||||
|
const analyze = env.ANALYZE === "true";
|
||||||
|
|
||||||
|
const plugins: PluginOption[] = [vue()];
|
||||||
|
|
||||||
|
if (isProd) {
|
||||||
|
plugins.push(
|
||||||
|
compression({
|
||||||
|
algorithms: ["gzip", "brotliCompress"],
|
||||||
|
threshold: 1024,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (analyze) {
|
||||||
|
plugins.push(
|
||||||
|
visualizer({
|
||||||
|
filename: "stats.html",
|
||||||
|
template: "treemap",
|
||||||
|
gzipSize: true,
|
||||||
|
brotliSize: true,
|
||||||
|
open: true,
|
||||||
|
}) as PluginOption,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
plugins: [vue()],
|
plugins,
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
"@": new URL("./src", import.meta.url).pathname,
|
"@": r("./src"),
|
||||||
"@geo/shared-types": new URL(
|
"@geo/shared-types": r("../../packages/shared-types/src/index.ts"),
|
||||||
"../../packages/shared-types/src/index.ts",
|
"@geo/http-client": r("../../packages/http-client/src/index.ts"),
|
||||||
import.meta.url,
|
|
||||||
).pathname,
|
|
||||||
"@geo/http-client": new URL(
|
|
||||||
"../../packages/http-client/src/index.ts",
|
|
||||||
import.meta.url,
|
|
||||||
).pathname,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
@@ -29,5 +54,95 @@ export default defineConfig(({ mode }) => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
esbuild: isProd ? { drop: ["console", "debugger"] } : undefined,
|
||||||
|
build: {
|
||||||
|
target: "es2022",
|
||||||
|
sourcemap: "hidden",
|
||||||
|
cssCodeSplit: true,
|
||||||
|
assetsInlineLimit: 4096,
|
||||||
|
chunkSizeWarningLimit: 800,
|
||||||
|
reportCompressedSize: false,
|
||||||
|
modulePreload: { polyfill: false },
|
||||||
|
rollupOptions: {
|
||||||
|
output: {
|
||||||
|
entryFileNames: "assets/js/[name]-[hash].js",
|
||||||
|
chunkFileNames: "assets/js/[name]-[hash].js",
|
||||||
|
assetFileNames: (info) => {
|
||||||
|
const name = info.names?.[0] ?? "";
|
||||||
|
if (/\.(png|jpe?g|gif|svg|webp|avif|ico)$/i.test(name)) {
|
||||||
|
return "assets/img/[name]-[hash][extname]";
|
||||||
|
}
|
||||||
|
if (/\.(woff2?|eot|ttf|otf)$/i.test(name)) {
|
||||||
|
return "assets/fonts/[name]-[hash][extname]";
|
||||||
|
}
|
||||||
|
if (/\.css$/i.test(name)) {
|
||||||
|
return "assets/css/[name]-[hash][extname]";
|
||||||
|
}
|
||||||
|
return "assets/[name]-[hash][extname]";
|
||||||
|
},
|
||||||
|
manualChunks(id) {
|
||||||
|
if (!id.includes("node_modules")) return undefined;
|
||||||
|
|
||||||
|
// Milkdown editor and its heavy companion deps (only the editor route
|
||||||
|
// imports them, so this chunk stays lazy-loaded).
|
||||||
|
if (
|
||||||
|
id.includes("/@milkdown/") ||
|
||||||
|
id.includes("/prosemirror-") ||
|
||||||
|
id.includes("/@codemirror/") ||
|
||||||
|
id.includes("/@lezer/") ||
|
||||||
|
id.includes("/katex/") ||
|
||||||
|
id.includes("/micromark") ||
|
||||||
|
id.includes("/mdast-util") ||
|
||||||
|
id.includes("/hast-util") ||
|
||||||
|
id.includes("/unified/") ||
|
||||||
|
id.includes("/remark") ||
|
||||||
|
id.includes("/rehype")
|
||||||
|
) {
|
||||||
|
return "milkdown";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
id.includes("/ant-design-vue/") ||
|
||||||
|
id.includes("/@ant-design/")
|
||||||
|
) {
|
||||||
|
return "antd";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (id.includes("/@tanstack/") || id.includes("/@vueuse/")) {
|
||||||
|
return "query";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (id.includes("/@jsquash/")) {
|
||||||
|
return "imaging";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (id.includes("/lodash") || id.includes("/dayjs")) {
|
||||||
|
return "utils";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
id.includes("/markdown-it") ||
|
||||||
|
id.includes("/dompurify") ||
|
||||||
|
id.includes("/entities/")
|
||||||
|
) {
|
||||||
|
return "editor-utils";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
id.includes("/vue/") ||
|
||||||
|
id.includes("/@vue/") ||
|
||||||
|
id.includes("/vue-router/") ||
|
||||||
|
id.includes("/vue-i18n/") ||
|
||||||
|
id.includes("/@intlify/") ||
|
||||||
|
id.includes("/pinia/")
|
||||||
|
) {
|
||||||
|
return "vue-vendor";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "vendor";
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -33,15 +33,15 @@
|
|||||||
"@playwright/test": "^1.0.0",
|
"@playwright/test": "^1.0.0",
|
||||||
"@types/node": "^24.0.0",
|
"@types/node": "^24.0.0",
|
||||||
"@types/ws": "^8.18.1",
|
"@types/ws": "^8.18.1",
|
||||||
"@vitejs/plugin-vue": "^5.2.4",
|
"@vitejs/plugin-vue": "^6.0.6",
|
||||||
"ant-design-vue": "^4.2.6",
|
"ant-design-vue": "^4.2.6",
|
||||||
"electron": "41.2.0",
|
"electron": "41.2.0",
|
||||||
"electron-builder": "^25.0.0",
|
"electron-builder": "^25.0.0",
|
||||||
"electron-vite": "^2.0.0",
|
"electron-vite": "^5.0.0",
|
||||||
"typescript": "^5.9.3",
|
"typescript": "^5.9.3",
|
||||||
"unplugin-vue-components": "^32.0.0",
|
"unplugin-vue-components": "^32.0.0",
|
||||||
"vite": "^5.4.19",
|
"vite": "^7.3.2",
|
||||||
"vitest": "^2.0.0",
|
"vitest": "^4.1.5",
|
||||||
"vue": "^3.5.31",
|
"vue": "^3.5.31",
|
||||||
"vue-router": "^4.5.1",
|
"vue-router": "^4.5.1",
|
||||||
"vue-tsc": "^3.2.6"
|
"vue-tsc": "^3.2.6"
|
||||||
|
|||||||
Generated
+416
-322
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user