41 lines
1.0 KiB
TypeScript
41 lines
1.0 KiB
TypeScript
import { defineConfig } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import AutoImport from 'unplugin-auto-import/vite'
|
|
import Components from 'unplugin-vue-components/vite'
|
|
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
|
|
import { fileURLToPath, URL } from 'node:url'
|
|
|
|
export default defineConfig(({ command }) => ({
|
|
base: '/',
|
|
plugins: [
|
|
vue(),
|
|
AutoImport({ resolvers: [ElementPlusResolver()] }),
|
|
// 生产构建时跳过 components.d.ts 生成,避免 Windows 下并发写文件触发 UNKNOWN 错误。
|
|
Components({
|
|
resolvers: [ElementPlusResolver()],
|
|
dts: command === 'serve'
|
|
})
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'@': fileURLToPath(new URL('./src', import.meta.url))
|
|
}
|
|
},
|
|
server: {
|
|
host: '0.0.0.0',
|
|
port: 5173,
|
|
proxy: {
|
|
'/api': {
|
|
target: 'http://127.0.0.1:8080',
|
|
changeOrigin: true
|
|
}
|
|
}
|
|
},
|
|
build: {
|
|
target: 'es2020',
|
|
outDir: 'dist',
|
|
sourcemap: false,
|
|
chunkSizeWarningLimit: 1500
|
|
}
|
|
}))
|