Files
cesnimda dabcc68b21
CI / quality (push) Successful in 2m3s
CI / e2e (push) Failing after 10s
CI / lighthouse (push) Failing after 10s
CI / relay (push) Successful in 49s
Deploy / deploy (push) Failing after 6s
CI / images (push) Has been skipped
fix: externalize hoisted scripts so CSP script-src 'self' allows them
Astro was inlining the theme/nav/observer bundle as <script type="module">.
The deployed nginx CSP blocks inline scripts, so the reveal observer never
ran and every [data-reveal] section stayed at opacity:0 (space reserved,
nothing visible). Force JS external via assetsInlineLimit.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-11 13:17:24 +02:00

46 lines
1.7 KiB
JavaScript

// @ts-check
import { defineConfig } from 'astro/config';
import tailwindcss from '@tailwindcss/vite';
import { fileURLToPath } from 'node:url';
// Canonical origin used for absolute URLs (sitemap, OG, hreflang, JSON-LD).
// Overridable at build time so staging emits its own origin. See DOCKER_SPEC §3.
const SITE = process.env.PUBLIC_SITE_URL ?? 'https://cesnimda.co.uk';
const r = (p) => fileURLToPath(new URL(p, import.meta.url));
// https://astro.build/config
export default defineConfig({
site: SITE,
// ROUTING_SPEC §1: trailing-slash canonical, directory output.
trailingSlash: 'always',
build: { format: 'directory', inlineStylesheets: 'auto' },
// I18N_SPEC §1: en at root, no prefixed. Localised slugs are handled by explicit
// page files + the slug map module (ARCHITECTURE A5), not automatic locale routing.
i18n: {
defaultLocale: 'en',
locales: ['en', 'no'],
routing: { prefixDefaultLocale: false, redirectToDefaultLocale: false },
},
prefetch: false,
compressHTML: true,
vite: {
plugins: [tailwindcss()],
// Never inline JS: the deployed CSP is `script-src 'self'`, which blocks inline
// <script> modules. Keep hoisted scripts as external /_astro/*.js so CSP allows them.
// (Images etc. fall back to the default inline threshold.)
build: { assetsInlineLimit: (file) => (file.endsWith('.js') ? false : undefined) },
resolve: {
alias: {
'@': r('./src'),
'@i18n': r('./src/i18n'),
'@components': r('./src/components'),
'@layouts': r('./src/layouts'),
'@styles': r('./src/styles'),
'@scripts': r('./src/scripts'),
'@lib': r('./src/lib'),
},
},
},
});