Files
summercms/admin/vite.config.ts
Jakub Zych a5e7dac10f feat(10.1-02): run registered toolbar actions and scope plugin CSS per controller
- ListToolbar renders server-filtered actions after delete as outline buttons, busy during their POST
- ListView posts {} to toolbar/{action}, toasts, reloads the list and refetches the header partial
- Lists load controller assets too, so other controllers' stylesheet links are disabled on every open
- Vite dev server proxies {prefix}/assets to summer serve; dist rebuilt
2026-09-29 02:13:26 +02:00

37 lines
1.3 KiB
TypeScript

import { defineConfig, type Plugin } from 'vite'
import vue from '@vitejs/plugin-vue'
import tailwindcss from '@tailwindcss/vite'
// The committed build is path-agnostic (D-02): assets use a relative base and
// index.html keeps the __SUMMER_ADMIN_BASE__ token, which the Go server
// (boardwalk) replaces with the configured backend.uri. The dev server
// replaces it with SUMMER_ADMIN_DEV_PREFIX and proxies the admin API and the
// plugin assets to a running `summer serve` at SUMMER_ADMIN_DEV_TARGET.
const devPrefix = (process.env.SUMMER_ADMIN_DEV_PREFIX ?? '/backend').replace(/\/+$/, '')
const devTarget = process.env.SUMMER_ADMIN_DEV_TARGET ?? 'http://localhost:8080'
function devBase(): Plugin {
return {
name: 'summer-admin-dev-base',
apply: 'serve',
transformIndexHtml: (html) => html.replace('__SUMMER_ADMIN_BASE__', devPrefix),
}
}
export default defineConfig(({ command }) => ({
base: command === 'build' ? './' : '/',
plugins: [vue(), tailwindcss(), devBase()],
build: {
outDir: '../modules/boardwalk/dist',
emptyOutDir: true,
sourcemap: false,
},
server: {
proxy: {
[`${devPrefix}/api`]: { target: devTarget, changeOrigin: false },
// Plugin JS/CSS that controllers declare (Phase 10.1), served by cabana.
[`${devPrefix}/assets`]: { target: devTarget, changeOrigin: false },
},
},
}))