Simplified templating, backend port config on devserver.py, simplified Vue app patches.

This commit is contained in:
2026-01-17 19:51:47 +00:00
parent d9323f34e1
commit a2983a62a0
7 changed files with 164 additions and 190 deletions
+16 -20
View File
@@ -6,34 +6,30 @@
* - Builds to the Python module's frontend-build directory
*
* Environment variables (with defaults):
* VITE_PORT=5173 - Vite dev server port
* VITE_BACKEND_URL=http://localhost:5180 - Backend API URL for proxying
* FASTAPI_VUE_BACKEND_URL=http://localhost:5180 - Backend API URL for proxying
*/
const backendUrl =
process.env.VITE_BACKEND_URL || "http://localhost:{{BACKEND_PORT}}";
const vitePort = parseInt(process.env.VITE_PORT || "{{VITE_PORT}}");
const backendUrl = process.env.FASTAPI_VUE_BACKEND_URL || "http://localhost:5180"
export default function fastapiVue({ paths = ["/api"] } = {}) {
// Build proxy configuration for each path
const proxy = {}
for (const path of paths) {
proxy[path] = {
target: backendUrl,
changeOrigin: false,
ws: true,
}
}
export default function fastapiVue() {
return {
name: "fastapi-vite",
config: () => ({
server: {
host: "localhost",
port: vitePort,
strictPort: true,
proxy: {
"/api": {
target: backendUrl,
changeOrigin: false,
ws: true,
},
},
},
server: { proxy },
build: {
outDir: "../{{MODULE_NAME}}/frontend-build",
outDir: "../MODULE_NAME/frontend-build",
emptyOutDir: true,
},
}),
};
}
}