64 lines
1.5 KiB
TypeScript
64 lines
1.5 KiB
TypeScript
import { defineConfig } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import { fileURLToPath, URL } from 'node:url'
|
|
import AutoImport from 'unplugin-auto-import/vite'
|
|
import Components from 'unplugin-vue-components/vite'
|
|
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig({
|
|
plugins: [
|
|
vue(),
|
|
// 自动导入 Vue 相关函数
|
|
AutoImport({
|
|
imports: ['vue', 'vue-router', 'pinia'],
|
|
dts: 'src/types/auto-imports.d.ts',
|
|
eslintrc: {
|
|
enabled: true
|
|
}
|
|
}),
|
|
// 自动导入组件
|
|
Components({
|
|
resolvers: [
|
|
AntDesignVueResolver({
|
|
importStyle: false // 使用 CSS 而不是 less
|
|
})
|
|
],
|
|
dts: 'src/types/components.d.ts'
|
|
})
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'@': fileURLToPath(new URL('./src', import.meta.url))
|
|
}
|
|
},
|
|
server: {
|
|
port: 3000,
|
|
proxy: {
|
|
'/api': {
|
|
target: 'http://localhost:8080',
|
|
changeOrigin: true,
|
|
rewrite: (path) => path.replace(/^\/api/, '')
|
|
}
|
|
}
|
|
},
|
|
build: {
|
|
rollupOptions: {
|
|
output: {
|
|
// 为每次构建生成唯一的文件名,避免缓存问题
|
|
entryFileNames: `assets/[name]-[hash]-${Date.now()}.js`,
|
|
chunkFileNames: `assets/[name]-[hash]-${Date.now()}.js`,
|
|
assetFileNames: `assets/[name]-[hash]-${Date.now()}.[ext]`
|
|
}
|
|
}
|
|
},
|
|
css: {
|
|
preprocessorOptions: {
|
|
scss: {
|
|
additionalData: '@import "@/styles/variables.scss";'
|
|
}
|
|
}
|
|
}
|
|
})
|
|
|