fix: 修改启动配置

This commit is contained in:
Edan's Win11
2025-06-03 21:22:15 +08:00
parent ecbcf1bcd2
commit 4e9b6cb1de
+23 -35
View File
@@ -1,49 +1,37 @@
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite' import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue' import vue from '@vitejs/plugin-vue'
// import vueDevTools from 'vite-plugin-vue-devtools' import { resolve } from 'path'
// https://vite.dev/config/ // https://vite.dev/config/
export default defineConfig({ export default defineConfig({
plugins: [ plugins: [vue()],
vue(),
// vueDevTools(),
],
resolve: { resolve: {
alias: { alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)), '@': resolve(__dirname, 'src'),
'@assets': fileURLToPath(new URL('./src/assets', import.meta.url)),
}, },
}, },
optimizeDeps: { css: {
exclude: ['fsevents'], preprocessorOptions: {
scss: {
// 移除自动导入,改用@use语法
}
}
}, },
server: { server: {
proxy: { port: 5173,
'/api': { open: true
target: 'http://localhost:5409', },
changeOrigin: true, build: {
rewrite: (path) => path.replace(/^\/api/, ''), outDir: 'dist',
// configure: (proxy, options) => { sourcemap: false,
// proxy.on('proxyReq', (proxyReq, req, res) => { chunkSizeWarningLimit: 1600,
// // 支持SSE连接 rollupOptions: {
// if (req.url && req.url.includes('/login')) { output: {
// proxyReq.setHeader('Accept', 'text/event-stream'); manualChunks: {
// proxyReq.setHeader('Cache-Control', 'no-cache'); vue: ['vue', 'vue-router', 'pinia'],
// proxyReq.setHeader('Connection', 'keep-alive'); elementPlus: ['element-plus'],
// } utils: ['axios']
// }); }
// proxy.on('proxyRes', (proxyRes, req, res) => {
// // 确保SSE响应头正确设置
// if (req.url && req.url.includes('/login')) {
// proxyRes.headers['content-type'] = 'text/event-stream';
// proxyRes.headers['cache-control'] = 'no-cache';
// proxyRes.headers['connection'] = 'keep-alive';
// proxyRes.headers['access-control-allow-origin'] = '*';
// }
// });
// }
} }
} }
} }