This repository has been archived on 2025-05-18. You can view files and clone it, but cannot push or open issues or pull requests.
assistant-base/vite.config.ts
2025-03-08 22:01:49 +08:00

60 lines
1.5 KiB
TypeScript
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.

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';
import tailwindcss from '@tailwindcss/vite';
import pkgs from './package.json' with { type: 'json' };
import basicSsl from '@vitejs/plugin-basic-ssl';
const version = pkgs.version || '0.0.1';
const isDev = process.env.NODE_ENV === 'development';
const basename = isDev ? '/' : pkgs?.basename || '/';
const plugins = []
const isWeb = false;
if(isWeb) {
// 在bolt.new的页面没有ssl
plugins.push(basicSsl())
}
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react(), tailwindcss(), ...plugins],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
base: basename,
define: {
DEV_SERVER: JSON.stringify(process.env.NODE_ENV === 'development'),
VERSION: JSON.stringify(version),
BASE_NAME: JSON.stringify(basename),
},
build: {
target: 'esnext',
},
server: {
port: 6004,
host: '0.0.0.0',
proxy: {
'/api': {
target: 'http://localhost:4005',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '/api'),
},
'/api/router': {
target: 'ws://localhost:4005',
changeOrigin: true,
ws: true,
rewriteWsOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '/api'),
},
'/client': {
target: 'https://localhost:51015',
changeOrigin: true,
secure: false, // 允许自签名证书
},
},
},
});