替换 vite 架构

This commit is contained in:
GeekMaster
2025-05-26 14:14:29 +08:00
parent 94a5187e75
commit b1ddcef593
20 changed files with 937 additions and 782 deletions

View File

@@ -1,27 +1,46 @@
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import path from 'path';
import vue from '@vitejs/plugin-vue'
import path from 'path'
import { defineConfig, loadEnv } from 'vite'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
server: {
port: 8888,
proxy: {
'/api': {
target: process.env.VUE_APP_API_HOST || 'http://localhost:8080', // Fallback if env var is not set
changeOrigin: true,
ws: true,
},
'/static/upload/': {
target: process.env.VUE_APP_API_HOST || 'http://localhost:8080', // Fallback if env var is not set
changeOrigin: true,
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd())
const apiHost = env.VITE_API_HOST || 'http://localhost:5678'
return {
plugins: [vue()],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
},
});
css: {
preprocessorOptions: {
stylus: {
additionalData: `@import "@/assets/css/index.styl";`,
},
},
},
optimizeDeps: {
include: ['stylus'],
},
server: {
port: 8888,
...(process.env.NODE_ENV === 'development'
? {
proxy: {
'/api': {
target: apiHost,
changeOrigin: true,
ws: true,
},
'/static/upload/': {
target: apiHost,
changeOrigin: true,
},
},
}
: {}),
},
}
})