37 lines
1.6 KiB
TypeScript
37 lines
1.6 KiB
TypeScript
import react from '@vitejs/plugin-react'
|
|
import { defineConfig } from 'vite'
|
|
|
|
// The development and preview servers pass /api and /docs to the manager VITE_MANAGER names; the shell's WebSocket keeps
|
|
// its Host, which the manager compares with its Origin.
|
|
const manager = process.env.VITE_MANAGER ?? 'http://127.0.0.1:7080'
|
|
const proxy = {
|
|
'/api/shell': { target: manager, ws: true },
|
|
'/api': { target: manager, changeOrigin: true },
|
|
'/docs': { target: manager, changeOrigin: true },
|
|
}
|
|
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
build: {
|
|
rolldownOptions: {
|
|
output: {
|
|
// Higher priorities are matched first; the application code stays in the entry chunk. Monaco has a chunk of its
|
|
// own, loaded only when the Shell page's editor opens; Vite's preload helper, which the entry and Monaco share,
|
|
// is kept out of it, so the entry does not load it.
|
|
codeSplitting: {
|
|
groups: [
|
|
{ name: 'preload', test: /vite[\\/]preload-helper/, priority: 50 },
|
|
{ name: 'monaco', test: /node_modules[\\/]monaco-editor[\\/]/, priority: 40 },
|
|
{ name: 'react', test: /node_modules[\\/](react|react-dom|scheduler)[\\/]/, priority: 30 },
|
|
{ name: 'mui', test: /node_modules[\\/](@mui|@emotion)[\\/]/, priority: 20 },
|
|
{ name: 'vendor', test: /node_modules[\\/]/, priority: 10 },
|
|
],
|
|
},
|
|
},
|
|
},
|
|
},
|
|
// Ports of their own, so manage-ui's servers can run at the same time.
|
|
server: { port: 5180, strictPort: true, proxy },
|
|
preview: { port: 4180, strictPort: true, proxy },
|
|
})
|