Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 10 additions & 26 deletions astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ import rehypeSlug from "rehype-slug"
import rehypeAutolinkHeadings from "rehype-autolink-headings"
import rehypeWrapAll from "rehype-wrap-all"
import sitemap from "@astrojs/sitemap"
import { RehypePlugins } from "@astrojs/markdown-remark"
import type { RehypePlugins } from "astro"
import yaml from "@rollup/plugin-yaml"
import { fileURLToPath } from "node:url"
import { ccipRedirects } from "./src/config/redirects/ccip"
import trailingSlashMiddleware from "./src/integrations/trailing-slash-middleware"
import redirectsJson from "./src/features/redirects/redirects.json"
import tailwindcss from "tailwindcss"
import autoprefixer from "autoprefixer"
import { extractCanonicalUrlsWithLanguageVariants } from "./src/utils/sidebar"
import { preactModulesMatcher } from "./src/utils/preactModules"
import { isSunsetDocsPath, SUNSET_PAGES_STAY_IN_SITEMAP } from "./src/config/sunset"
import remarkCodeFenceFilename from "./src/lib/markdown/remarkCodeFenceFilename"
import remarkCodeFenceLanguageAlias from "./src/lib/markdown/remarkCodeFenceLanguageAlias"
Expand All @@ -41,6 +43,9 @@ const redirectSources = new Set(
// Only the actual content pages (-go, -ts) are indexed
const canonicalUrlsWithLanguageVariants = extractCanonicalUrlsWithLanguageVariants()

// Preact files (`@jsxImportSource preact` pragma) and the barrels that only re-export them; everything else is React
const preactModules = preactModulesMatcher(fileURLToPath(new URL(".", import.meta.url)))

// https://astro.build/config
export default defineConfig({
site: "https://docs.chain.link",
Expand All @@ -55,10 +60,11 @@ export default defineConfig({
integrations: [
trailingSlashMiddleware(),
preact({
include: ["**/preact/*"],
include: [preactModules],
}),
react({
include: ["**/react/*"],
// Also keep node_modules out: a custom `exclude` replaces @vitejs/plugin-react's default node_modules exclusion
exclude: [preactModules, /\/node_modules\//],
}),
sitemap({
changefreq: "daily",
Expand Down Expand Up @@ -151,26 +157,7 @@ export default defineConfig({
output: "static",
adapter: vercel(),
vite: {
plugins: [
yaml(),
// Dev-only workaround for slow `astro dev`: @chainlink/blocks ships raw TS whose root entry
// re-exports ~3,700 icon modules, and Astro's dev server crawls the whole module graph on every request.
// Pre-bundling blocks for SSR collapses it into a single module. Remove once blocks ships a built package.
{
name: "dev-prebundle-chainlink-blocks",
apply: "serve",
config: () => ({
ssr: {
noExternal: ["@chainlink/blocks"],
optimizeDeps: {
include: ["@chainlink/blocks"],
exclude: ["react", "react-dom"], // keep a single React instance (react-dom/server stays external)
esbuildOptions: { jsx: "automatic" }, // blocks relies on the automatic JSX runtime
},
},
}),
},
],
plugins: [yaml()],
build: {
target: "esnext", // Use latest ES features, no transpilation for modern browsers
// Optimize CSS delivery
Expand All @@ -195,7 +182,4 @@ export default defineConfig({
},
},
},
legacy: {
collections: false,
},
})
Loading
Loading