修复生产前端 Rolldown 分包循环依赖白屏,补齐画布引用排序与素材 payload 合同,并同步工作流生成素材字段。 Co-authored-by: Cursor <cursoragent@cursor.com>
79 lines
2.9 KiB
TypeScript
79 lines
2.9 KiB
TypeScript
import { dirname, resolve } from "node:path";
|
|
import { readFileSync } from "node:fs";
|
|
import { fileURLToPath } from "node:url";
|
|
import react from "@vitejs/plugin-react";
|
|
import { defineConfig } from "vite";
|
|
|
|
const webDir = dirname(fileURLToPath(import.meta.url));
|
|
const appVersion = process.env.CANVAS_BUILD_VERSION?.trim() || readFileSync(resolve(webDir, "../VERSION"), "utf8").trim();
|
|
const appChangelog = readFileSync(resolve(webDir, "../CHANGELOG.md"), "utf8");
|
|
const apiProxyTarget = process.env.VITE_API_PROXY_TARGET?.trim() || "http://127.0.0.1:8080";
|
|
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
define: {
|
|
__APP_VERSION__: JSON.stringify(appVersion),
|
|
__APP_CHANGELOG__: JSON.stringify(appChangelog),
|
|
"import.meta.env.VITE_APP_VERSION": JSON.stringify(appVersion),
|
|
},
|
|
server: {
|
|
proxy: {
|
|
"/api": {
|
|
target: apiProxyTarget,
|
|
changeOrigin: true,
|
|
xfwd: true,
|
|
},
|
|
"/oauth/linuxdo/callback": {
|
|
target: apiProxyTarget,
|
|
changeOrigin: true,
|
|
xfwd: true,
|
|
},
|
|
},
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
"@": resolve(webDir, "src"),
|
|
},
|
|
},
|
|
build: {
|
|
rolldownOptions: {
|
|
output: {
|
|
strictExecutionOrder: true,
|
|
codeSplitting: {
|
|
includeDependenciesRecursively: true,
|
|
minSize: 20 * 1024,
|
|
groups: [
|
|
{
|
|
name: "vendor-react",
|
|
test: /node_modules[\\/](?:react(?:-dom|-router|-router-dom)?|scheduler|zustand|use-sync-external-store|@tanstack[\\/](?:query-core|react-query))[\\/]/,
|
|
priority: 30,
|
|
},
|
|
{
|
|
name: "vendor-icons",
|
|
test: /node_modules[\\/](?:lucide-react|@ant-design[\\/]icons)[\\/]/,
|
|
priority: 20,
|
|
entriesAware: true,
|
|
entriesAwareMergeThreshold: 48 * 1024,
|
|
},
|
|
{
|
|
name: "vendor-antd",
|
|
test: /node_modules[\\/](?:antd|@ant-design|@rc-component|rc-[^\\/]+|dayjs)[\\/]/,
|
|
priority: 10,
|
|
entriesAware: true,
|
|
entriesAwareMergeThreshold: 80 * 1024,
|
|
},
|
|
{
|
|
name: "app-shared",
|
|
test: /[\\/]src[\\/]/,
|
|
priority: 5,
|
|
minShareCount: 2,
|
|
entriesAware: true,
|
|
entriesAwareMergeThreshold: 48 * 1024,
|
|
},
|
|
],
|
|
},
|
|
},
|
|
},
|
|
},
|
|
});
|