fix: 修改启动配置
This commit is contained in:
+24
-36
@@ -1,50 +1,38 @@
|
||||
import { fileURLToPath, URL } from 'node:url'
|
||||
|
||||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
// import vueDevTools from 'vite-plugin-vue-devtools'
|
||||
import { resolve } from 'path'
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
vue(),
|
||||
// vueDevTools(),
|
||||
],
|
||||
plugins: [vue()],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||||
'@assets': fileURLToPath(new URL('./src/assets', import.meta.url)),
|
||||
'@': resolve(__dirname, 'src'),
|
||||
},
|
||||
},
|
||||
optimizeDeps: {
|
||||
exclude: ['fsevents'],
|
||||
css: {
|
||||
preprocessorOptions: {
|
||||
scss: {
|
||||
// 移除自动导入,改用@use语法
|
||||
}
|
||||
}
|
||||
},
|
||||
server: {
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://localhost:5409',
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/api/, ''),
|
||||
// configure: (proxy, options) => {
|
||||
// proxy.on('proxyReq', (proxyReq, req, res) => {
|
||||
// // 支持SSE连接
|
||||
// if (req.url && req.url.includes('/login')) {
|
||||
// proxyReq.setHeader('Accept', 'text/event-stream');
|
||||
// proxyReq.setHeader('Cache-Control', 'no-cache');
|
||||
// proxyReq.setHeader('Connection', 'keep-alive');
|
||||
// }
|
||||
// });
|
||||
// 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'] = '*';
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
port: 5173,
|
||||
open: true
|
||||
},
|
||||
build: {
|
||||
outDir: 'dist',
|
||||
sourcemap: false,
|
||||
chunkSizeWarningLimit: 1600,
|
||||
rollupOptions: {
|
||||
output: {
|
||||
manualChunks: {
|
||||
vue: ['vue', 'vue-router', 'pinia'],
|
||||
elementPlus: ['element-plus'],
|
||||
utils: ['axios']
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user