|
|
@ -1,10 +1,13 @@
|
|
|
|
import path from 'path'
|
|
|
|
import path from 'path'
|
|
|
|
import { defineConfig, loadEnv } from 'vite'
|
|
|
|
import { defineConfig, loadEnv } from 'vite'
|
|
|
|
import vue from '@vitejs/plugin-vue'
|
|
|
|
import vue from '@vitejs/plugin-vue'
|
|
|
|
|
|
|
|
import { createViteProxy } from './config'
|
|
|
|
|
|
|
|
|
|
|
|
export default defineConfig((env) => {
|
|
|
|
export default defineConfig((env) => {
|
|
|
|
const viteEnv = loadEnv(env.mode, process.cwd()) as unknown as ImportMetaEnv
|
|
|
|
const viteEnv = loadEnv(env.mode, process.cwd()) as unknown as ImportMetaEnv
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const isOpenProxy = viteEnv.VITE_GLOB_HTTP_PROXY === 'Y'
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
resolve: {
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
alias: {
|
|
|
@ -13,16 +16,10 @@ export default defineConfig((env) => {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
plugins: [vue()],
|
|
|
|
plugins: [vue()],
|
|
|
|
server: {
|
|
|
|
server: {
|
|
|
|
port: 1002,
|
|
|
|
|
|
|
|
host: '0.0.0.0',
|
|
|
|
host: '0.0.0.0',
|
|
|
|
|
|
|
|
port: 1002,
|
|
|
|
open: false,
|
|
|
|
open: false,
|
|
|
|
proxy: {
|
|
|
|
proxy: createViteProxy(isOpenProxy, viteEnv),
|
|
|
|
'/api': {
|
|
|
|
|
|
|
|
target: viteEnv.VITE_APP_API_BASE_URL,
|
|
|
|
|
|
|
|
changeOrigin: true, // 允许跨域
|
|
|
|
|
|
|
|
rewrite: path => path.replace('/api/', '/'),
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
build: {
|
|
|
|
build: {
|
|
|
|
reportCompressedSize: false,
|
|
|
|
reportCompressedSize: false,
|
|
|
|