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