writekit/frontends/owner-tools/vite.config.ts

43 lines
961 B
TypeScript
Raw Normal View History

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import UnoCSS from 'unocss/vite'
import { resolve } from 'path'
export default defineConfig(({ command }) => ({
plugins: [UnoCSS(), ...(command === 'build' ? [react()] : [])],
base: command === 'serve' ? '/@owner-tools' : '/',
esbuild: {
jsxInject: `import React from 'react'`
},
...(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
}
}))