Skip to content

Commit 7ea80a8

Browse files
committed
site: Migrate from webpack to Astro
Rebuilds the docs site on Astro, replacing the custom webpack setup: a client and a server render build, an HTML render plugin, a docs manifest generator, an MDX loader, and a webpack loader that compiled code blocks. Pages are now static HTML. React only runs in the parts of the page that need it (Astro "islands"), instead of hydrating the whole site as one app. ## Pages and layout - `layouts/Layout.astro` replaces the `<head>` from `render.tsx`, including the colour mode script and the font preload. - `pages/index.astro` renders the homepage. The search input, colour mode toggle and GitHub stars are passed in as islands, and the code samples are highlighted at build time. - `pages/documentation/[...slug].astro` renders each docs page from a content collection (`content.config.ts`). Page order and grouping still come from `contents.ts`. - `DocsPage` is split into `DocsChrome` (header, primary nav and mobile menu, an island), `SecondaryNav` (an island), and `DocsMain` (static). - `useActiveHeading` replaces `useHeadingRoute`. It highlights the heading in the secondary nav using `IntersectionObserver`, and no longer rewrites the URL hash while scrolling. - `Link` and `ButtonLink` render plain anchors, replacing `react-router-dom` and `react-router-hash-link`. - Legacy routes become Astro `redirects`, and static assets move to `public/`. ## Docs content - A satteri mdast plugin (`markdown/docsPlugin.ts`) replaces `code-block-loader.js`. Astro passes MDX components their children as pre-rendered HTML, so the plugin handles anything that depends on the markdown's structure: - Code blocks are highlighted with Shiki and rendered with `CodeBlock`. A leading `// file.ts` comment becomes the title. - ` ```ts compiled ` blocks are compiled with `@vanilla-extract/compiler` (`markdown/compileVanillaExtract.ts`), and the CSS is shown alongside. Each block's files are served from a virtual directory named by a hash of its contents, so blocks can't import each other and edits never hit stale modules. An Astro integration closes the compiler when the build or dev server finishes. - Links whose only child is inline code, and paragraphs in blockquotes, are marked so `mdx-components.tsx` can style them. - Shiki's CSS variables theme is used, with colours set per colour mode in `Code/highlighting.css.ts` and scope overrides chosen to match the old Prism colours. This replaces `react-syntax-highlighter` and `ErrorHighlighter`; homepage type errors are underlined with Shiki decorations. - Compiled code blocks are hydrated islands (`MdxCompiledCode`), as switching files and showing the CSS output use React state. ## Tooling - The site has its own `tsconfig.json`, and is type-checked with `astro check` (`pnpm lint:site`, included in `pnpm lint`) instead of the root `tsc`. - CI no longer generates a docs manifest. - DocSearch and its Algolia dependencies are bundled for server rendering, as their ESM builds can't be imported by Node. - Removes webpack, Babel, the docs manifest and indexer, and their dependencies. - `CONTRIBUTING.md` mentions Astro. - Updates a `@vanilla-extract/rollup-plugin` snapshot. Astro's dependencies move Vite to 8.3, which needs rolldown 1.2, and pnpm dedupes the plugin's `rolldown` dev dependency to the same version. Rolldown 1.2 hoists two calls in the bundled output into `const`s, without changing their order.
1 parent 38797b6 commit 7ea80a8

56 files changed

Lines changed: 3820 additions & 3573 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/validate.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
run: pnpm install
3535

3636
- name: Build
37-
run: pnpm build && pnpm --filter "./site" generate:docs-manifest
37+
run: pnpm build
3838

3939
- name: Lint
4040
run: pnpm lint

‎.prettierignore‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ dist
55
CHANGELOG.md
66
README.md
77
.github/ISSUE_TEMPLATE
8-
site/docs-manifest.json
8+
site/.astro
99
.changeset
1010
.next
1111
pnpm-lock.yaml

‎CONTRIBUTING.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Run `pnpm format` to fix any violations that can be automatically fixed.
8989

9090
## Updating documentation
9191

92-
The Vanilla Extract docs site is authored in [MDX] files located at [/site/docs].
92+
The Vanilla Extract docs site is built with [Astro], and authored in [MDX] files located at [/site/docs].
9393
To start the docs site locally run `pnpm start-site`.
9494

9595
MDX is stricter than markdown: a bare `<` or `{` in text must be escaped (e.g. `&lt;`), and HTML comments aren't supported.
@@ -100,6 +100,7 @@ If your change requires a new page on the documentation site and you're not sure
100100
If for whatever reason you are unable to write documentation to accompany your change, a maintainer can make the necessary changes for you in a separate PR.
101101

102102
[/site/docs]: ./site/docs
103+
[Astro]: https://astro.build
103104
[MDX]: https://mdxjs.com
104105

105106
## Writing a changeset

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"lint:manypkg": "manypkg check",
2323
"lint:prettier": "prettier --cache --check .",
2424
"lint:tsc": "tsc",
25+
"lint:site": "pnpm --filter=site lint",
2526
"lint:oxlint": "oxlint",
2627
"copy-readme-to-packages": "node scripts/copy-readme-to-packages.ts",
2728
"version": "changeset version && pnpm install --lockfile-only",

‎packages/rollup-plugin/test/__snapshots__/rollup-plugin.test.ts.snap‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2695,9 +2695,10 @@ const blankVar1 = createVar({
26952695
inherits: false,
26962696
initialValue: "0.5"
26972697
}, "blankVar1");
2698+
const blankVar2 = createVar("blankVar2");
26982699
const opacity = styleVariants({
26992700
"1/2": blankVar1,
2700-
"1/4": fallbackVar(blankVar1, createVar("blankVar2"), "0.25")
2701+
"1/4": fallbackVar(blankVar1, blankVar2, "0.25")
27012702
}, (value) => ({ selectors: { "html &": { opacity: value } } }), "opacity");
27022703
endFileScope();
27032704
//#endregion
@@ -2753,8 +2754,9 @@ const altTheme = createTheme(vars, {
27532754
3: "16px"
27542755
}
27552756
}, "altTheme");
2757+
const themeLayer = layer("themeLayer");
27562758
const [altTheme2Class, altTheme2Contract] = createTheme({
2757-
"@layer": layer("themeLayer"),
2759+
"@layer": themeLayer,
27582760
colors: {
27592761
backgroundColor: "green",
27602762
text: "white"

0 commit comments

Comments
 (0)