import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import { fileURLToPath, URL } from 'node:url' export default defineConfig({ // 插件数组 plugins: [vue()], // 路径别名 resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)), '~': fileURLToPath(new URL('./src', import.meta.url)) } }, css: { preprocessorOptions: { // 全局引入variable.scss scss: { additionalData: `@import "@/styles/variables.scss";` } } }, build: { // 构建为库模式 lib: { entry: fileURLToPath(new URL('./src/index.ts', import.meta.url)), name: 'KnowAIUI', fileName: (format) => `knowai-ui.${format}.js` }, rollupOptions: { // 不打包进库 external: ['vue'], output: { globals: { vue: 'Vue' } } } } })