vite.config.ts
712 Bytes
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { fileURLToPath, URL } from 'node:url';
// 库构建配置:产出 ESM 到 dist/,并将 react / react-dom / antd 标记为外部依赖,
// 由使用方提供同一份实例。开发态由应用侧直接引用 src(见 package.json exports)。
export default defineConfig({
plugins: [react()],
resolve: {
alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) },
},
build: {
lib: {
entry: fileURLToPath(new URL('./src/index.ts', import.meta.url)),
formats: ['es'],
fileName: 'uj-ui',
},
rollupOptions: {
external: ['react', 'react-dom', 'antd'],
},
},
});