Files
cas_tt_cloud_web/vite.config.js
2022-03-09 11:55:10 +08:00

39 lines
1.1 KiB
JavaScript

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
'/api': {
// target: 'http://localhost:8080',
target: 'http://192.168.0.149:8000',
// target: 'http://101.34.131.16:8000',
// target: 'http://zky.server.ipeace.org.cn',
changeOrigin: true,
rewrite: (p) => p.replace(/^\/api/, '/api')
}
},
},
}
})