2021-12-29 11:25:14 +08:00
|
|
|
import { defineConfig, loadEnv } from 'vite'
|
|
|
|
import path from 'path'
|
|
|
|
import createVitePlugins from './vite/plugins'
|
|
|
|
|
|
|
|
// https://vitejs.dev/config/
|
|
|
|
export default defineConfig(({ mode, command }) => {
|
|
|
|
const env = loadEnv(mode, process.cwd())
|
|
|
|
return {
|
|
|
|
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: {
|
|
|
|
port: 80,
|
|
|
|
open: true,
|
|
|
|
proxy: {
|
|
|
|
// https://cn.vitejs.dev/config/#server-proxy
|
2022-03-01 17:57:20 +08:00
|
|
|
'/api': {
|
|
|
|
// target: 'http://localhost:8080',
|
|
|
|
target: 'http://192.168.0.149:8000',
|
2022-03-09 11:55:10 +08:00
|
|
|
// target: 'http://101.34.131.16:8000',
|
2022-03-01 17:57:20 +08:00
|
|
|
// target: 'http://zky.server.ipeace.org.cn',
|
2021-12-29 11:25:14 +08:00
|
|
|
changeOrigin: true,
|
2022-03-01 17:57:20 +08:00
|
|
|
rewrite: (p) => p.replace(/^\/api/, '/api')
|
2021-12-29 11:25:14 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
})
|