530308033b
`/hikes` is `prerender = true` and carries the global nav, so the prerender crawler followed those links and tried to statically render the whole dynamic, DB-/ML-backed app. SvelteKit prerenders inside a heap-capped worker_threads worker, so this exhausted its heap (ERR_WORKER_OUT_OF_MEMORY) and failed the build. - svelte.config.js: prerender.crawl = false. The intended static set is fully described by `prerender = true` (/hikes) + the /errors/[status] EntryGenerator, so crawling is unneeded. Add a defensive handleHttpError that ignores /hikes/*/images/* 404s (those binaries live in hikes-assets/, served by nginx/dev-middleware, not /static). - hooks.server.ts: skip init when `building` so builds don't connect to Mongo, start the payment scheduler, or warm the romcal cache. - hikes/[slug]: set `prerender = false`, enforcing the intent its comment already stated. Version 1.86.1 -> 1.86.2.
58 lines
2.4 KiB
JavaScript
58 lines
2.4 KiB
JavaScript
import adapter from '@sveltejs/adapter-node';
|
|
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
|
import { mdsvex } from 'mdsvex';
|
|
|
|
/** @type {import('@sveltejs/kit').Config} */
|
|
const config = {
|
|
extensions: ['.svelte', '.svx'],
|
|
preprocess: [
|
|
vitePreprocess(),
|
|
mdsvex({
|
|
extensions: ['.svx'],
|
|
layout: {
|
|
hike: 'src/lib/components/hikes/HikeMdxLayout.svelte'
|
|
}
|
|
})
|
|
],
|
|
kit: {
|
|
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
|
|
// If your environment is not supported or you settled on a specific environment, switch out the adapter.
|
|
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
|
|
adapter: adapter({
|
|
precompress: true // Enable brotli and gzip compression
|
|
}),
|
|
prerender: {
|
|
// The only intentionally-static pages are /hikes (prerender=true) and
|
|
// the /errors/[status] set (via that route's EntryGenerator). With the
|
|
// crawler on, it follows the global nav out of /hikes and tries to
|
|
// prerender the whole dynamic, DB-/ML-backed app — which runs the
|
|
// forked prerender worker out of heap (ERR_WORKER_OUT_OF_MEMORY) and
|
|
// fails the build. Disable crawling: the prerendered set is then driven
|
|
// entirely by `prerender = true` + EntryGenerator.
|
|
crawl: false,
|
|
handleHttpError: ({ path, message }) => {
|
|
// Defensive: hike image binaries live in `hikes-assets/`, outside
|
|
// `/static` (nginx serves them in prod, a Vite middleware in dev —
|
|
// see vite.config.ts), so the crawler can't fetch them. Harmless
|
|
// while crawl is off, but keeps a 404 from failing the build if
|
|
// crawling is ever re-enabled.
|
|
if (/^\/hikes\/[^/]+\/images\//.test(path)) return;
|
|
throw new Error(message);
|
|
}
|
|
},
|
|
alias: {
|
|
$models: 'src/models',
|
|
$utils: 'src/utils',
|
|
$types: 'src/types',
|
|
// romcal ships the 1969 bundles inside its workspace dir but does not
|
|
// re-export them, so exports-field resolution blocks a direct import. Point
|
|
// the scoped package names at the bundle directories so both the TS types
|
|
// (index.d.ts) and the ESM entry (esm/index.js) resolve via their package.json.
|
|
'@romcal/calendar.general-roman': 'node_modules/romcal/rites/roman1969/dist/bundles/general-roman',
|
|
'@romcal/calendar.switzerland': 'node_modules/romcal/rites/roman1969/dist/bundles/switzerland'
|
|
}
|
|
}
|
|
};
|
|
|
|
export default config;
|