74 lines
2.0 KiB
JavaScript
74 lines
2.0 KiB
JavaScript
// @ts-check
|
|
import { defineConfig } from 'astro/config';
|
|
import node from '@astrojs/node';
|
|
import tailwindcss from '@tailwindcss/vite';
|
|
import preact from '@astrojs/preact';
|
|
|
|
const isDev = process.env.NODE_ENV === 'development';
|
|
|
|
// CSV iz env-a: "localhost,127.0.0.1,serviseri-004.captain.mitteworkspace.cloud"
|
|
const envHosts = (process.env.PUBLIC_ALLOWED_HOSTS || '')
|
|
.split(',')
|
|
.map((h) => h.trim())
|
|
.filter(Boolean);
|
|
|
|
const allowedHosts = Array.from(
|
|
new Set(['localhost', '127.0.0.1', 'serviseri-004.captain.mitteworkspace.cloud', ...envHosts])
|
|
);
|
|
|
|
const hmrHost = process.env.PUBLIC_HMR_HOST || 'localhost';
|
|
const hmrProtocol = process.env.PUBLIC_HMR_PROTOCOL || 'ws';
|
|
const hmrClientPort = Number(process.env.PUBLIC_HMR_CLIENT_PORT || 4321);
|
|
|
|
export default defineConfig({
|
|
output: 'server',
|
|
adapter: node({ mode: 'standalone' }),
|
|
|
|
server: {
|
|
host: true,
|
|
port: 4321,
|
|
allowedHosts,
|
|
},
|
|
|
|
vite: {
|
|
resolve: {
|
|
alias: {
|
|
react: 'preact/compat',
|
|
'react-dom': 'preact/compat',
|
|
'react-dom/test-utils': 'preact/test-utils',
|
|
'react/jsx-runtime': 'preact/jsx-runtime',
|
|
'react/jsx-dev-runtime': 'preact/jsx-dev-runtime',
|
|
},
|
|
},
|
|
define: {
|
|
__PUSHER_KEY__: JSON.stringify(process.env.PUBLIC_PUSHER_KEY || process.env.PUSHER_KEY || ''),
|
|
__PUSHER_CLUSTER__: JSON.stringify(process.env.PUBLIC_PUSHER_CLUSTER || process.env.PUSHER_CLUSTER || ''),
|
|
},
|
|
ssr: {
|
|
noExternal: ['@react-spring/web', '@react-spring/core', '@react-spring/animated', '@react-spring/shared'],
|
|
},
|
|
build: {
|
|
assetsInlineLimit: 1024,
|
|
},
|
|
plugins: [tailwindcss()],
|
|
server: isDev
|
|
? {
|
|
allowedHosts,
|
|
hmr: {
|
|
protocol: hmrProtocol, // ws ili wss
|
|
host: hmrHost,
|
|
clientPort: hmrClientPort,
|
|
},
|
|
watch: {
|
|
usePolling: true,
|
|
interval: 100,
|
|
},
|
|
}
|
|
: {
|
|
allowedHosts,
|
|
},
|
|
},
|
|
|
|
integrations: [preact()],
|
|
});
|