93773f3887
Includes FastAPI backend, vendored step2urdf frontend, and A7 handtuned arm JSON for URDF generation.
86 lines
2.4 KiB
TypeScript
86 lines
2.4 KiB
TypeScript
import { fileURLToPath, URL } from "node:url";
|
||
|
||
import { defineConfig } from "vite";
|
||
import vue from "@vitejs/plugin-vue";
|
||
import { resolve } from "path";
|
||
import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
|
||
// https://vite.dev/config/
|
||
export default defineConfig({
|
||
plugins: [vue(), createSvgIconsPlugin({
|
||
iconDirs: [resolve(process.cwd(), "src/assets/svgs")],
|
||
symbolId: "icon-[dir]-[name]"
|
||
})],
|
||
// 包含 wasm 文件作为静态资源
|
||
assetsInclude: ['**/*.wasm'],
|
||
// opencascade.js 不能被 Vite 预构建优化
|
||
// jszip/comlink: ExportWorker 懒加载;若不预构建,首次点「导出 URDF」会触发
|
||
// Vite “new dependencies optimized → reloading”,整页刷新导致模型丢失、ZIP 下不来。
|
||
optimizeDeps: {
|
||
exclude: ['opencascade.js'],
|
||
include: ['jszip', 'comlink']
|
||
},
|
||
// Worker 构建配置
|
||
worker: {
|
||
format: 'es', // 使用 ES module 格式,支持 Worker 内 dynamic import
|
||
rollupOptions: {
|
||
output: {
|
||
// Worker 输出格式
|
||
format: 'es'
|
||
}
|
||
}
|
||
},
|
||
resolve: {
|
||
alias: {
|
||
"@": fileURLToPath(new URL("./src", import.meta.url))
|
||
}
|
||
},
|
||
server: {
|
||
host: "0.0.0.0",
|
||
port: 5678,
|
||
open: true,
|
||
headers: {
|
||
'Cross-Origin-Opener-Policy': 'same-origin',
|
||
'Cross-Origin-Embedder-Policy': 'require-corp'
|
||
},
|
||
proxy: {
|
||
// Proxy LLM / helper API to local FastAPI (Zhipu key stays server-side)
|
||
"/api": {
|
||
target: "http://127.0.0.1:8787",
|
||
changeOrigin: true,
|
||
}
|
||
}
|
||
},
|
||
css: {
|
||
preprocessorOptions: {
|
||
scss: {
|
||
api: 'modern',
|
||
}
|
||
}
|
||
},
|
||
build: {
|
||
outDir: "dist",
|
||
minify: "esbuild",
|
||
// esbuild 打包更快,但是不能去除 console.log,terser打包慢,但能去除 console.log
|
||
// minify: "terser",
|
||
// terserOptions: {
|
||
// compress: {
|
||
// drop_console: viteEnv.VITE_DROP_CONSOLE,
|
||
// drop_debugger: true
|
||
// }
|
||
// },
|
||
sourcemap: false,
|
||
// 禁用 gzip 压缩大小报告,可略微减少打包时间
|
||
reportCompressedSize: false,
|
||
// 规定触发警告的 chunk 大小
|
||
chunkSizeWarningLimit: 2000,
|
||
rollupOptions: {
|
||
output: {
|
||
// Static resource classification and packaging
|
||
chunkFileNames: "assets/js/[name]-[hash].js",
|
||
entryFileNames: "assets/js/[name]-[hash].js",
|
||
assetFileNames: "assets/[ext]/[name]-[hash].[ext]"
|
||
}
|
||
}
|
||
}
|
||
});
|