43 lines
960 B
TypeScript
43 lines
960 B
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: [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/build/assets/js',
|
||
|
|
emptyOutDir: false
|
||
|
|
}
|
||
|
|
}))
|