Repository navigation
Expand file tree
/
Copy pathastro.config.ts
More file actions
145 lines (143 loc) · 5.51 KB
/
Copy pathastro.config.ts
File metadata and controls
145 lines (143 loc) · 5.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import { fileURLToPath } from 'node:url';
import { defineConfig } from 'astro/config';
import tailwind from '@astrojs/tailwind';
import sitemap from '@astrojs/sitemap';
import sentry from "@sentry/astro";
// The docs MDX pipeline (react + mdx + remark/rehype/Shiki) and route
// generation, inlined from the former @rivet-dev/docs-theme package.
import { docsPipeline } from './src/integrations/docs-pipeline';
import { redirects } from './redirects.mjs';
import { getRouteSeoPolicy } from './src/lib/routeSeoPolicy';
// Wildcard sub-path redirects (`wildcardRedirects` in redirects.mjs) are applied
// only at the Caddy layer in production. Astro's static output treats a redirect
// key containing a rest param (`[...slug]`) as a dynamic route that needs
// `getStaticPaths`, so feeding external-URL wildcards here aborts the build. The
// explicit non-wildcard entries below still cover every real former route on the
// dev server; deep sub-paths fall through to Caddy in production.
export default defineConfig({
site: 'https://rivet.dev',
output: 'static',
trailingSlash: 'ignore',
image: {
// Allow build-time optimization of artwork hosted on the assets CDN.
domains: ['assets.rivet.dev'],
},
server: {
allowedHosts: [
'30025-ikymhvv49x5x9ih5uanjw.e2b.app',
'.onamp.dev',
],
},
// SEO Redirects - Astro generates HTML redirect files for static builds and
// serves them on the dev server. The same map drives real HTTP 301s at the
// Caddy layer in production (see scripts/generate-caddy-redirects.mjs), so it
// lives in a shared module to keep the two from drifting.
redirects: redirects,
prefetch: {
prefetchAll: true,
defaultStrategy: 'hover',
},
build: {
assets: '_astro',
format: 'directory',
},
// markdown (.md) remark/rehype + syntaxHighlight:false are configured by
// docsPipeline()'s markdown integration; .mdx is handled by its mdx().
integrations: [
...docsPipeline(),
tailwind({
applyBaseStyles: false,
}),
sitemap({
// The same policy emits page-level robots directives and decides sitemap
// membership, so a hidden route cannot accidentally be submitted.
filter: (page) => getRouteSeoPolicy(page).sitemap,
}),
sentry({
project: "website",
org: "rivet-gaming",
authToken: process.env.SENTRY_AUTH_TOKEN,
}),
],
vite: {
build: {
rollupOptions: {
output: {
// One-time asset-URL rotation (base64 -> hex hashes), 2026-08-31.
// A deploy-window 404 for a /_astro/ chunk was cached alongside the
// immutable Cache-Control header by browsers, and content-hashed
// URLs never change on their own, so those clients replay the 404
// forever and the Header/Footer islands die on the failed import.
// New URLs sidestep every poisoned cache entry.
hashCharacters: 'hex',
},
},
},
resolve: {
// Product docs are symlinked in from their own repos, so Vite resolves
// bare specifiers relative to the *source* repo, which has no copy of
// these. Aliasing to the local packages lets product MDX import shared
// components and icons regardless of where the bundle is checked out.
alias: {
'@rivet-gg/icons': fileURLToPath(new URL('./packages/icons/dist/index.js', import.meta.url)),
},
},
// Mermaid is large and only dynamically imported by MermaidScript, so Vite
// discovers it late and re-optimizes mid-session, which invalidates the
// in-flight chunk and serves a 504 "Outdated Optimize Dep" for every
// diagram. Pre-bundling it at server start keeps its chunk hash stable.
// The island deps below fail the same way: they enter through deep island
// graphs (Header, DocsNavigation, Footer), so on a cold server they get
// discovered mid-hydration, the re-optimize invalidates the in-flight
// import chain, and every large island on the page silently fails to
// hydrate — docs sidebar dropdowns dead until a lucky reload.
//
// `@rivet-gg/components` is a linked workspace package, which Vite serves
// as raw source in dev: its barrel `src/index.ts` fans out to ~130
// separate module requests on every page that imports even `cn`, and on
// a high-latency link that waterfall dominates page load. Listing it
// here pre-bundles it into a handful of chunks like any other dep. The
// cost is that edits inside packages/components need a dev-server
// restart (or `astro dev --force`) instead of HMR. Production builds are
// unaffected: optimizeDeps only applies to the dev server. Subpath
// entries are separate optimizer entries, so list each one the site
// imports; those resolve to `.tsx` files, which Vite refuses to treat
// as optimizable entries unless the extension is listed.
optimizeDeps: {
extensions: ['.tsx'],
include: [
'@rivet-gg/components',
'@rivet-gg/components/header',
'@rivet-gg/components/mdx',
'mermaid',
'framer-motion',
'@rivet-gg/icons',
'clsx',
'sonner',
'@radix-ui/react-slot',
'@radix-ui/react-visually-hidden',
'react-hook-form',
'@hookform/resolvers/zod',
],
},
ssr: {
noExternal: ['@rivet-gg/components', '@rivet-gg/icons'],
},
server: {
fs: {
// Allow serving files from the monorepo root for artifacts
allow: ['..'],
},
// Pre-transform the heavy always-on-page island entries so a cold dev
// server has their graphs ready before the first hydration attempt.
warmup: {
clientFiles: [
'./src/components/v2/Header.tsx',
'./src/components/DocsNavigation.tsx',
'./src/components/Footer.jsx',
'./src/components/Providers.jsx',
],
},
},
},
});