Files
dss/admin-ui/vite.config.ts
2025-12-11 18:55:57 -03:00

81 lines
2.1 KiB
TypeScript

import { defineConfig } from 'vite';
import preact from '@preact/preset-vite';
import { VitePWA } from 'vite-plugin-pwa';
import { resolve } from 'path';
export default defineConfig(({ mode }) => ({
plugins: [
preact(),
// Only enable PWA in production - it interferes with HMR in dev
mode === 'production' && VitePWA({
registerType: 'autoUpdate',
includeAssets: ['favicon.ico', 'robots.txt', 'apple-touch-icon.png'],
manifest: {
name: 'DSS Admin',
short_name: 'DSS',
description: 'Design System Server Administration',
theme_color: '#0f172a',
background_color: '#ffffff',
display: 'standalone',
icons: [
{
src: 'pwa-192x192.png',
sizes: '192x192',
type: 'image/png'
},
{
src: 'pwa-512x512.png',
sizes: '512x512',
type: 'image/png'
}
]
},
workbox: {
globPatterns: ['**/*.{js,css,html,ico,png,svg}'],
runtimeCaching: [
{
urlPattern: /^\/api\/.*/i,
handler: 'NetworkFirst',
options: {
cacheName: 'api-cache',
expiration: {
maxEntries: 100,
maxAgeSeconds: 60 * 60 // 1 hour
}
}
}
]
}
})
].filter(Boolean),
resolve: {
alias: {
'@': resolve(__dirname, './src'),
'react': 'preact/compat',
'react-dom': 'preact/compat'
}
},
server: {
host: '0.0.0.0', // Bind to all interfaces for nginx proxy compatibility
port: 6221, // DSS Admin UI port
allowedHosts: ['dss.overbits.luz.uy', 'localhost', '.localhost'], // Allow external domain and localhost
proxy: {
'/api': {
target: 'http://localhost:6220', // DSS API port
changeOrigin: true
}
}
},
build: {
outDir: 'dist',
sourcemap: true,
rollupOptions: {
output: {
manualChunks: {
'preact': ['preact', '@preact/signals']
}
}
}
}
}));