writekit/frontends/owner-tools/vite.config.ts
Josh 6ba25d0113
All checks were successful
ci/woodpecker/push/build Pipeline was successful
fix(owner-tools): resolve merge conflict and fix UnoCSS build
- Use UnoCSS CLI to pre-generate CSS for production build
- Add prebuild script to generate uno-generated.css
- Alias to virtual:uno.css in dev mode for HMR
- Remove UnoCSS vite plugin from build (only use in dev)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 02:51:07 +02:00

52 lines
1.2 KiB
TypeScript

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import UnoCSS from 'unocss/vite'
import { resolve } from 'path'
export default defineConfig(({ command }) => ({
plugins: [
// Only use UnoCSS plugin in dev mode for HMR
...(command === 'serve' ? [UnoCSS()] : []),
...(command === 'build' ? [react()] : []),
],
base: command === 'serve' ? '/@owner-tools' : '/',
esbuild: {
jsxInject: `import React from 'react'`
},
resolve: {
alias: command === 'serve' ? {
// In dev mode, alias the generated file to virtual:uno.css
'./uno-generated.css': 'virtual:uno.css',
} : {},
},
...(command === 'serve' && {
server: {
host: true,
port: 5174,
strictPort: true,
allowedHosts: true,
hmr: {
clientPort: 80,
path: '/@owner-tools'
},
proxy: {
'/api/studio': {
target: 'http://app:8080',
changeOrigin: true
}
}
}
}),
build: {
lib: {
entry: resolve(__dirname, 'src/main.tsx'),
name: 'OwnerTools',
formats: ['iife'],
fileName: () => 'owner-tools.js'
},
outDir: '../../internal/tenant/assets/js',
emptyOutDir: false
}
}))