53 lines
1.1 KiB
TypeScript
53 lines
1.1 KiB
TypeScript
import {defineConfig, loadEnv} from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import path from 'path'
|
|
import { fileURLToPath } from 'url'
|
|
|
|
export default defineConfig(({mode, command}) => {
|
|
const env = loadEnv(mode, process.cwd())
|
|
const {VITE_API_BASE} = env
|
|
return {
|
|
resolve: {
|
|
alias: {
|
|
// 设置路径
|
|
'~': path.resolve(__dirname, './'),
|
|
// 设置别名
|
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
// 资源地址
|
|
'@assets': path.resolve(__dirname, 'src/assets')
|
|
},
|
|
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
|
|
},
|
|
base: '/',
|
|
// vite 相关配置
|
|
server: {
|
|
port: 8611,
|
|
host: true,
|
|
// open: true,
|
|
proxy: {
|
|
'/api': {
|
|
target: VITE_API_BASE,
|
|
changeOrigin: true,
|
|
rewrite: (p) => p.replace(/^\/api/, '')
|
|
}
|
|
}
|
|
},
|
|
build: {
|
|
outDir: 'dist',
|
|
assetsDir: 'static',
|
|
chunkSizeWarningLimit: 2000,
|
|
sourcemap: true,
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks(id) {
|
|
if (id.includes('node_modules')) {
|
|
return 'vendor'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
plugins: [vue()]
|
|
}
|
|
})
|