brf/vite.config.js
2025-11-23 21:44:01 +01:00

35 lines
988 B
JavaScript

import { defineConfig } from 'vite'
import { preact } from '@preact/preset-vite'
export default defineConfig(({ isSsrBuild }) => {
const entry = process.env.VITE_ENTRY || 'public'
return {
plugins: [preact()],
root: new URL('./client', import.meta.url).pathname,
publicDir: new URL('./client/static', import.meta.url).pathname,
build: {
outDir: new URL('./dist', import.meta.url).pathname,
emptyOutDir: false,
sourcemap: true,
assetsInlineLimit: 0,
copyPublicDir: !isSsrBuild && entry === 'public',
manifest: isSsrBuild ? null : `manifest.${entry}.json`,
rollupOptions: {
input: {
[entry]: new URL(`./client/${entry}/${isSsrBuild ? 'server' : 'client'}.ts`, import.meta.url).pathname,
},
},
},
server: {
allowedHosts: ['startbit.local'],
port: 1338,
hmr: process.env.VITE_HMR_PROXY
? {
clientPort: 443,
}
: false,
},
}
})