80 lines
1.9 KiB
JavaScript
80 lines
1.9 KiB
JavaScript
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 Icons from 'unplugin-icons/vite'
|
|
import IconsResolver from 'unplugin-icons/resolver'
|
|
import path from 'path'
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig({
|
|
plugins: [
|
|
vue(),
|
|
AutoImport({
|
|
resolvers: [ElementPlusResolver()],
|
|
imports: ['vue', 'vue-router', 'vue-i18n'],
|
|
dts: false,
|
|
}),
|
|
Components({
|
|
resolvers: [
|
|
ElementPlusResolver({ importStyle: 'css' }),
|
|
IconsResolver({
|
|
prefix: 'i',
|
|
enabledCollections: ['feather'],
|
|
}),
|
|
],
|
|
dts: false,
|
|
}),
|
|
Icons({ compiler: 'vue3', autoInstall: true }),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, './src'),
|
|
// '@deotaland/ui': path.resolve(__dirname, '../../packages/ui'), // 临时注释,修复部署问题
|
|
},
|
|
},
|
|
// Vercel 部署优化配置 - 修复CORS问题
|
|
base: '/',
|
|
build: {
|
|
outDir: 'dist',
|
|
assetsDir: 'assets',
|
|
sourcemap: false,
|
|
minify: 'terser',
|
|
terserOptions: {
|
|
compress: {
|
|
drop_console: true,
|
|
drop_debugger: true
|
|
},
|
|
format: {
|
|
comments: false
|
|
}
|
|
},
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks: {
|
|
vendor: ['vue', 'vue-router', 'vue-i18n'],
|
|
elementPlus: ['element-plus'],
|
|
utils: ['axios', 'dayjs']
|
|
}
|
|
}
|
|
}
|
|
},
|
|
server: {
|
|
port: 3000,
|
|
host: true,
|
|
// 配置代理解决CORS问题
|
|
proxy: {
|
|
'/api': {
|
|
target: 'https://api.deotaland.ai',
|
|
changeOrigin: true,
|
|
rewrite: (path) => path.replace(/^\/api/, '')
|
|
}
|
|
}
|
|
},
|
|
preview: {
|
|
port: 3000,
|
|
host: true
|
|
}
|
|
})
|