12345678910111213141516171819202122232425262728293031 |
- import { defineConfig, loadEnv } from 'vite'
- import vue from '@vitejs/plugin-vue'
- import path from 'path'
- export default defineConfig(({ mode }) => {
- const env = loadEnv(mode, process.cwd())
- const { VITE_USE_PROXY, VITE_API_BASE_URL, VITE_PROXY_TARGET } = env
-
- return {
- plugins: [vue()],
- resolve: {
- alias: {
- '@': path.resolve(__dirname, './src')
- }
- },
- build: {
- outDir: mode === 'production' ? 'dist-prod' : 'dist-test'
- },
- server: {
- port: 3000,
- open: true,
- proxy: VITE_USE_PROXY === 'true' ? {
- [VITE_API_BASE_URL]: {
- target: VITE_PROXY_TARGET,
- changeOrigin: true,
- rewrite: (path) => path.replace(new RegExp('^' + VITE_API_BASE_URL), '')
- }
- } : {}
- }
- }
- })
|