Files
rainblogweb/vite.config.js
T

33 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const { defineConfig } = require('vite');
const react = require('@vitejs/plugin-react');
const path = require('path');
module.exports = defineConfig({
plugins: [react()],
root: path.resolve(__dirname, 'frontend'),
base: '/',
build: {
outDir: path.resolve(__dirname, 'public/dist'),
emptyOutDir: true,
rollupOptions: {
input: {
main: path.resolve(__dirname, 'frontend/index.html'),
admin: path.resolve(__dirname, 'frontend/admin.html'),
},
},
},
server: {
port: 5173,
proxy: {
'/api': 'http://localhost:3101',
'/uploads': 'http://localhost:3101',
// 面板代理前缀 /proxy/{slug}/dev 下 iframe 与预热 fetch 走这里转发到后端
//ws:true 让面板 WebSocket 也能在 dev 下工作,生产由 server.js upgrade 事件处理)
'/proxy': { target: 'http://localhost:3101', ws: true },
// Web 终端 WS/ws/terminal 必须走 WebSocket 代理,否则 dev 下解锁后
// 连接永远失败 → 终端空转白屏(生产由 server.js 的 upgrade 事件处理)
'/ws': { target: 'ws://localhost:3101', ws: true },
},
},
});