49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
import { fileURLToPath, URL } from "node:url";
|
|
import { defineConfig } from "vite";
|
|
import vue from "@vitejs/plugin-vue";
|
|
|
|
// 构建产物写入 Go 内嵌目录,开发态将 /api 代理到后端。
|
|
export default defineConfig({
|
|
plugins: [
|
|
vue({
|
|
template: {
|
|
compilerOptions: {
|
|
isCustomElement: (tag) => tag.startsWith("media-"),
|
|
},
|
|
},
|
|
}),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
"@": fileURLToPath(new URL("./src", import.meta.url)),
|
|
},
|
|
},
|
|
server: {
|
|
port: 5173,
|
|
proxy: {
|
|
"/api": {
|
|
target: process.env.LITEPAN_API_PROXY || "http://127.0.0.1:5211",
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
},
|
|
build: {
|
|
outDir: "../internal/api/web",
|
|
emptyOutDir: true,
|
|
// 解码器按需分包,阈值略高于当前最大独立产物。
|
|
chunkSizeWarningLimit: 3200,
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks(id) {
|
|
if (id.includes('node_modules/three')) {
|
|
return 'three-vendor';
|
|
}
|
|
if (id.includes('node_modules/vue') || id.includes('node_modules/pinia') || id.includes('node_modules/vue-router')) {
|
|
return 'vue-vendor';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
});
|