bjscar/vite.config.ts
2025-11-16 18:35:14 +08:00

34 lines
1.2 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import vue from '@vitejs/plugin-vue';
import process from 'node:process';
import { fileURLToPath, URL } from 'node:url';
import { defineConfig } from 'vite';
import topLevelAwait from 'vite-plugin-top-level-await';
// https://vite.dev/config/
export default defineConfig({
plugins: [vue(), topLevelAwait()],
base: process.env.NODE_ENV === 'production' ? '/tmp/car/' : '/',
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
build: {
target: ['edge90', 'chrome90', 'firefox90', 'safari15'],
lib: {
entry: "src/3d/load3d.ts", // 入口文件路径
// entry: 'src/components/design/Design.ts', // 入口文件路径
name: "bjscar", // 全局变量名UMD 格式时生效)
fileName: (format) => `bjscar.${format}.js`, // 输出文件名模板
// formats: ['es', 'umd', 'system'] // 输出格式ES 模块、UMD 等)
// formats: ['es'] // 输出格式ES 模块)
formats: ["umd"], // 输出格式ES 模块、UMD 等)
},
rollupOptions: {
// 确保外部化处理那些你不想打包进库的依赖
// external: ['vue', /^@babylonjs\//, 'three', 'three-addons']
external: ['vue', 'three', 'three-addons']
}
}
})