29 lines
764 B
TypeScript
29 lines
764 B
TypeScript
import { defineConfig } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
import { readFileSync } from 'node:fs';
|
|
|
|
// 以 package.json 的 version 作为客户端版本号唯一来源,注入到前端
|
|
const pkg = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf-8'));
|
|
|
|
// 浏览器调试与 Electron 开发共用
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
define: {
|
|
__APP_VERSION__: JSON.stringify(pkg.version),
|
|
},
|
|
base: './',
|
|
server: {
|
|
port: 5173,
|
|
host: '127.0.0.1',
|
|
proxy: {
|
|
'/api': 'http://localhost:3000',
|
|
'/uploads': 'http://localhost:3000',
|
|
'/socket.io': { target: 'http://localhost:3000', ws: true },
|
|
},
|
|
},
|
|
build: {
|
|
outDir: 'dist',
|
|
emptyOutDir: true,
|
|
},
|
|
});
|