mirror of
https://github.com/yangjian102621/geekai.git
synced 2026-04-26 21:14:27 +08:00
替换 vite 架构
This commit is contained in:
@@ -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,
|
||||
},
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user