This commit is contained in:
2025-03-18 16:14:40 +08:00
parent 25def8c245
commit aa1cee7c9f
50 changed files with 916 additions and 502 deletions

View File

@@ -2,9 +2,9 @@ import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';
import tailwindcss from '@tailwindcss/vite';
import basicSsl from '@vitejs/plugin-basic-ssl';
const isDev = process.env.NODE_ENV === 'development';
const isKV = process.env.VITE_USE_KV === 'true'; // use kevisual service as backend
const unamiPlugin = {
name: 'html-transform',
transformIndexHtml(html: string) {
@@ -14,30 +14,38 @@ const unamiPlugin = {
);
},
};
const plugins = [];
const plugins: any[] = [basicSsl()];
if (!isDev) {
plugins.push(unamiPlugin);
}
plugins.push(tailwindcss());
const devBackend = 'https://kevisual.silkyai.cn';
const meBackend = 'https://kevisual.xiongxiao.me';
// const backend = isDev ? devBackend : meBackend;
const backendWss = devBackend.replace(/^https:/, 'wss:');
const backend = devBackend;
let proxy = {};
if (isKV) {
if (true) {
proxy = {
'/api': {
target: 'https://kevisual.xiongxiao.me',
target: backend,
changeOrigin: true,
ws: true,
rewrite: (path: any) => path.replace(/^\/api/, '/api'),
},
'/api/router': {
target: 'wss://kevisual.xiongxiao.me',
target: backendWss,
changeOrigin: true,
ws: true,
rewriteWsOrigin: true,
rewrite: (path: any) => path.replace(/^\/api/, '/api'),
},
'/resources': {
target: 'https://kevisual.xiongxiao.me',
'/user/login': {
target: backend,
changeOrigin: true,
rewrite: (path: any) => path.replace(/^\/resources/, '/resources'),
cookieDomainRewrite: 'localhost',
rewrite: (path: any) => path.replace(/^\/user/, '/user'),
},
};
}
@@ -66,22 +74,17 @@ export default defineConfig({
changeOrigin: true,
},
'/api': {
target: 'http://localhost:4005',
target: 'https://localhost:4005',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '/api'),
},
'/api/router': {
target: 'ws://localhost:4005',
target: 'wss://localhost:4005',
changeOrigin: true,
ws: true,
rewriteWsOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '/api'),
},
'/resources': {
target: 'https://kevisual.xiongxiao.me',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/resources/, '/resources'),
},
...proxy,
},
},