patch astro frontend config file
This commit is contained in:
@@ -3,20 +3,31 @@ 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';
|
||||
|
||||
// https://astro.build/config
|
||||
// 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', ...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' }),
|
||||
|
||||
adapter: node({
|
||||
mode: 'standalone'
|
||||
}),
|
||||
|
||||
// 🛰️ Postavke razvojnog poslužitelja unutar Docker mreže
|
||||
server: {
|
||||
host: true, // Sluša na 0.0.0.0 unutar kontejnera
|
||||
port: 4321, // Unutarnji port kontejnera
|
||||
host: true,
|
||||
port: 4321,
|
||||
allowedHosts,
|
||||
},
|
||||
|
||||
vite: {
|
||||
@@ -40,23 +51,23 @@ export default defineConfig({
|
||||
assetsInlineLimit: 1024,
|
||||
},
|
||||
plugins: [tailwindcss()],
|
||||
|
||||
// ⚙️ Ugrađene preporuke za Docker File Watching i Tihi Refresh (HMR)
|
||||
server: isDev ? {
|
||||
hmr: {
|
||||
protocol: 'ws',
|
||||
host: 'localhost',
|
||||
// Mora odgovarati mapiranom portu u docker-compose (4321:4321)
|
||||
clientPort: 4321,
|
||||
},
|
||||
watch: {
|
||||
// Prisiljava Vite na "polling" sustav jer Windows/WSL2 volumeni nekad blokiraju inotify signale
|
||||
usePolling: true,
|
||||
interval: 100,
|
||||
}
|
||||
} : {}, // U produkciji je ovaj blok potpuno prazan radi maksimalnih performansi
|
||||
server: isDev
|
||||
? {
|
||||
allowedHosts,
|
||||
hmr: {
|
||||
protocol: hmrProtocol, // ws ili wss
|
||||
host: hmrHost,
|
||||
clientPort: hmrClientPort,
|
||||
},
|
||||
watch: {
|
||||
usePolling: true,
|
||||
interval: 100,
|
||||
},
|
||||
}
|
||||
: {
|
||||
allowedHosts,
|
||||
},
|
||||
},
|
||||
|
||||
// Redoslijed integracija: Tailwind pa Preact
|
||||
integrations: [preact()],
|
||||
});
|
||||
Reference in New Issue
Block a user