Files
treg/frontend/vite.agent-setup.config.ts
SToneX 83c999a943 perf(dashboard): compile the shared onboarding widgets and drop Vue's runtime template compiler
The agent picker, setup instructions and Try it out widgets were runtime template strings in
src/treg/web/agent-setup.js, which forced the Dashboard to alias vue to its compiler build.
Their one source is now frontend/src/agent-setup/ (typed data plus three SFCs): the Dashboard
imports it, and a second Vite build compiles the same modules into the classic /agent-setup.js
script that Enrich Arena loads on its global Vue build.
2026-09-27 19:55:28 +08:00

26 lines
1.2 KiB
TypeScript

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { fileURLToPath } from 'node:url'
// `/agent-setup.js` for Enrich Arena, a standalone page that runs on Vue's global build rather than
// the Dashboard bundle. The source is `src/agent-setup/`, which the Dashboard imports directly; this
// build compiles the same components to render functions, keeps `vue` as the page's global `Vue`,
// and exposes the module as `window.TregAgentSetup`. Runs after the Dashboard build, into its
// output directory, so the one generated tree holds every compiled browser asset.
export default defineConfig({
plugins: [vue({ template: { transformAssetUrls: { includeAbsolute: false } } })],
publicDir: false,
define: { 'process.env.NODE_ENV': JSON.stringify('production') },
build: {
outDir: fileURLToPath(new URL('../src/treg/web/dashboard', import.meta.url)),
emptyOutDir: false,
lib: {
entry: fileURLToPath(new URL('src/agent-setup/index.ts', import.meta.url)),
formats: ['iife'],
name: 'TregAgentSetup',
fileName: () => 'agent-setup.js',
},
rolldownOptions: { external: ['vue'], output: { globals: { vue: 'Vue' } } },
},
})