47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
|
|
import { defineConfig, loadEnv } from 'vite'
|
||
|
|
import react from '@vitejs/plugin-react'
|
||
|
|
import path from 'path'
|
||
|
|
|
||
|
|
export default defineConfig(({ mode }) => {
|
||
|
|
const env = loadEnv(mode, process.cwd(), '')
|
||
|
|
|
||
|
|
return {
|
||
|
|
plugins: [react()],
|
||
|
|
base: env.VITE_BASE_PATH || '/',
|
||
|
|
resolve: {
|
||
|
|
alias: {
|
||
|
|
'@': path.resolve(__dirname, './src'),
|
||
|
|
},
|
||
|
|
},
|
||
|
|
server: {
|
||
|
|
port: 3000,
|
||
|
|
host: true,
|
||
|
|
},
|
||
|
|
build: {
|
||
|
|
outDir: 'dist',
|
||
|
|
assetsDir: 'assets',
|
||
|
|
sourcemap: false,
|
||
|
|
rollupOptions: {
|
||
|
|
output: {
|
||
|
|
manualChunks: {
|
||
|
|
'vendor': ['react', 'react-dom', 'react-router-dom'],
|
||
|
|
'antd': ['antd', '@ant-design/icons'],
|
||
|
|
'charts': ['echarts', 'echarts-for-react'],
|
||
|
|
'redux': ['@reduxjs/toolkit', 'react-redux'],
|
||
|
|
},
|
||
|
|
},
|
||
|
|
},
|
||
|
|
},
|
||
|
|
define: {
|
||
|
|
__APP_CONFIG__: JSON.stringify({
|
||
|
|
domain: env.VITE_DOMAIN,
|
||
|
|
port: env.VITE_PORT,
|
||
|
|
basePath: env.VITE_BASE_PATH,
|
||
|
|
apiPrefix: env.VITE_API_PREFIX,
|
||
|
|
useHttps: env.VITE_USE_HTTPS === 'true',
|
||
|
|
timeout: parseInt(env.VITE_TIMEOUT || '30000'),
|
||
|
|
}),
|
||
|
|
},
|
||
|
|
}
|
||
|
|
})
|