39 lines
971 B
JavaScript
39 lines
971 B
JavaScript
/**
|
|
* FastAPI-Vue Vite Plugin
|
|
* auto-upgrade@fastapi-vue-setup -- remove this if you edit the plugin
|
|
*
|
|
* Configures Vite for FastAPI backend integration:
|
|
* - Proxies /api/* requests to the FastAPI backend
|
|
* - Builds to the Python module's frontend-build directory
|
|
* - Disables Vite's screen clearing on startup
|
|
*
|
|
* Options:
|
|
* paths - Array of paths to proxy (default: ['/api'])
|
|
*/
|
|
|
|
export default function fastapiVue({ paths = ['/api'] } = {}) {
|
|
const backendUrl = process.env.PAGERITE_BACKEND_URL || 'http://localhost:8210'
|
|
|
|
// Build proxy configuration for each path
|
|
const proxy = {}
|
|
for (const path of paths) {
|
|
proxy[path] = {
|
|
target: backendUrl,
|
|
changeOrigin: false,
|
|
ws: true,
|
|
}
|
|
}
|
|
|
|
return {
|
|
name: 'vite-plugin-fastapi-pagerite',
|
|
config: () => ({
|
|
clearScreen: false,
|
|
server: { proxy },
|
|
build: {
|
|
outDir: '../pagerite/frontend-build',
|
|
emptyOutDir: true,
|
|
},
|
|
}),
|
|
}
|
|
}
|