patch astro frontend config file
Some checks failed
ERP CI/CD Pipeline / test (push) Has been cancelled
ERP CI/CD Pipeline / Deploy (server git pull + compose) (push) Has been cancelled

This commit is contained in:
mariomitte
2026-07-10 23:22:53 +02:00
parent 4c9b6bba96
commit f8cf28b0a3

View File

@@ -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 ? {
server: isDev
? {
allowedHosts,
hmr: {
protocol: 'ws',
host: 'localhost',
// Mora odgovarati mapiranom portu u docker-compose (4321:4321)
clientPort: 4321,
protocol: hmrProtocol, // ws ili wss
host: hmrHost,
clientPort: hmrClientPort,
},
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
: {
allowedHosts,
},
},
// Redoslijed integracija: Tailwind pa Preact
integrations: [preact()],
});