| 1234567891011121314151617181920212223242526272829303132333435363738 |
- import { defineConfig, loadEnv } from 'vite'
- import vue from '@vitejs/plugin-vue'
- import path from 'path'
- // 引入@vitejs/plugin-legacy
- import legacy from '@vitejs/plugin-legacy'
- // https://vite.dev/config/
- export default defineConfig(({ mode }) => {
- // 加载对应模式的环境变量
- const env = loadEnv(mode, process.cwd())
- return {
- plugins: [
- legacy({
- targets: ['defaults', 'not IE 11']
- }),
- vue(),
- ],
- resolve: {
- // 路径别名配置
- alias: {
- '@': path.resolve(__dirname, './src')
- }
- },
- base: './',
- server: {
- host: '0.0.0.0',
- proxy: {
- '/admin-api': {
- // 使用加载的环境变量
- target: env.VITE_BASE_URL,
- changeOrigin: true
- }
- }
- }
- }
- })
|