63 lines
1.9 KiB
JavaScript
63 lines
1.9 KiB
JavaScript
import {defineConfig, loadEnv} from 'vite'
|
|
import path from 'path'
|
|
import createVitePlugins from './vite/plugins'
|
|
|
|
export default defineConfig(({mode, command}) => {
|
|
const env = loadEnv(mode, process.cwd())
|
|
const {VITE_APP_ENV} = env
|
|
return {
|
|
base: VITE_APP_ENV === 'production' ? '/' : '/',
|
|
plugins: createVitePlugins(env, command === 'build'),
|
|
resolve: {
|
|
// https://cn.vitejs.dev/config/#resolve-alias
|
|
alias: {
|
|
// 设置路径
|
|
'~':
|
|
path.resolve(__dirname, './'),
|
|
// 设置别名
|
|
'@':
|
|
path.resolve(__dirname, './src')
|
|
}
|
|
,
|
|
// https://cn.vitejs.dev/config/#resolve-extensions
|
|
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
|
|
}
|
|
,
|
|
// vite 相关配置
|
|
server: {
|
|
hmr: true,
|
|
port:
|
|
8099,
|
|
host:
|
|
true,
|
|
open:
|
|
true,
|
|
proxy:
|
|
{
|
|
// https://cn.vitejs.dev/config/#server-proxy
|
|
'/dev-api':
|
|
{
|
|
target: 'http://localhost:8083',
|
|
// target: 'http://110.153.1.138:8081',
|
|
changeOrigin:
|
|
true,
|
|
rewrite:
|
|
(p) => p.replace(/^\/dev-api/, ''),
|
|
}
|
|
,
|
|
'/prod-api':
|
|
{
|
|
target: 'http://110.153.1.138:8081',
|
|
changeOrigin:
|
|
true,
|
|
rewrite:
|
|
(p) => p.replace(/^\/prod-api/, '/prod-api/'),
|
|
}
|
|
}
|
|
}
|
|
,
|
|
}
|
|
|
|
|
|
})
|