You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

44 lines
1.1 KiB

import { fileURLToPath, URL } from 'node:url'
import type { ProxyOptions } from 'vite'
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import DefineOptions from 'unplugin-vue-define-options/vite'
const envDir = './env'
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const ENV = loadEnv(mode, envDir)
const prefix = process.env.VITE_DYNAMIC_PREFIX || ENV.VITE_BASE_PATH;
const proxyConf: Record<string, string | ProxyOptions> = {}
proxyConf['/api'] = {
target: 'https://mb.jzce.com',
changeOrigin: true,
rewrite: (path) => path.replace(ENV.VITE_BASE_PATH, '/')
}
return {
preflight: false,
lintOnSave: false,
base: prefix,
envDir: envDir,
plugins: [vue(), DefineOptions()],
server: {
cors: true,
host: '0.0.0.0',
port: Number(ENV.VITE_APP_PORT),
strictPort: true,
proxy: proxyConf,
mimeTypes: {
'application/javascript': ['js']
}
},
build: {
outDir: 'dist'
},
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
}
}
})