feat: 搭建前后端可执行程序示例
This commit is contained in:
25
vite.config.ts
Normal file
25
vite.config.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import react from "@vitejs/plugin-react";
|
||||
import { defineConfig } from "vite";
|
||||
|
||||
const backendPort = Number(process.env.BACKEND_PORT ?? process.env.PORT ?? 3000);
|
||||
|
||||
export default defineConfig({
|
||||
root: "src/web",
|
||||
plugins: [react()],
|
||||
server: {
|
||||
host: "127.0.0.1",
|
||||
port: 5173,
|
||||
strictPort: true,
|
||||
proxy: {
|
||||
"/api": {
|
||||
target: `http://127.0.0.1:${backendPort}`,
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
build: {
|
||||
outDir: "../../dist/web",
|
||||
emptyOutDir: true,
|
||||
assetsDir: "assets",
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user