Skip to content

fix(ci): build the docs site in production mode so search works - #721

Merged
jbouder merged 1 commit into
mainfrom
fix-search-prod-build
Sep 15, 2026
Merged

jbouder merged 1 commit into
mainfrom
fix-search-prod-build

Conversation

@jbouder

@jbouder jbouder commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Problem

Search is broken on https://www.nebari.dev — opening the search dialog shows "Search is only available in production builds. Try building and previewing the site to test it out locally."

Cause

The deployed HTML was built with NODE_ENV=test, so Vite treated the build as non-production and import.meta.env.DEV was true. Starlight's Search.astro then renders the dev-warning branch instead of the <div id="starlight__search"> container Pagefind mounts into.

The chain:

  1. The Docs workflow's only build step is bun test test — there is no separate bun run build.
  2. bun test sets NODE_ENV=test, and child processes inherit it.
  3. test/build.test.ts runs bun run build inside beforeAll, so the site build inherited NODE_ENV=test.
  4. wrangler deploy uploads that dist/ to the Worker.

The Pagefind index itself was always fine ([starlight:pagefind] Found 115 HTML files, dist/pagefind/ populated) — the page just never mounted the UI that queries it.

build command Search is only available in production builds in dist/index.html
bun run build 0 — renders <div class="search-container"><div id="starlight__search">
NODE_ENV=test bun run build 1 — dev notice, no search container

Changes

  • test/build.test.ts: the beforeAll build runs with NODE_ENV: 'production', so the dist/ the suite produces is deployable both locally and in CI.
  • .github/workflows/docs.yml: NODE_ENV: production on the step that builds the deployed dist/, so the value is visible where the deploy happens. (bun test respects a preset NODE_ENV rather than overwriting it.)
  • New regression test, pages mount the search UI instead of the dev-only notice: for the home page and one page per section, the HTML must contain id="starlight__search" and must not contain the dev notice. The search index is generated test also now checks pagefind-entry.json.

Verification

  • NODE_ENV=production SITE=https://www.nebari.dev BASE=/ bun test test (what CI runs): 6 pass, 0 fail.
  • Flipping the env back to test: 5 pass, 1 fail — the new test, on the missing id="starlight__search". The guard catches the regression rather than passing vacuously.

Search on the live site stays broken until this merges and the Docs workflow redeploys; the preview deploy on this PR should have working search.

🤖 Generated with Claude Code

`bun test` sets NODE_ENV=test and child processes inherit it, so the
`bun run build` inside the suite's `beforeAll` ran with Vite in
non-production mode. That made `import.meta.env.DEV` true, and Starlight
rendered its "Search is only available in production builds" notice in
place of the `#starlight__search` container Pagefind mounts into. Since
CI deploys the `dist/` that step produces, search was broken on
nebari.dev even though the Pagefind index itself was built fine.

Force NODE_ENV=production for the build (and on the CI step that runs
it), and add a regression test asserting every section's pages mount the
search UI instead of the dev-only notice.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@netlify

netlify Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

❌ Deploy Preview for nebari-docs2 failed.

Name Link
🔨 Latest commit b818b84
🔍 Latest deploy log https://app.netlify.com/projects/nebari-docs2/deploys/6aa96ec1c7c4900008155be1

@github-actions

Copy link
Copy Markdown

Docs preview for fix-search-prod-build (via the nebari-docs Worker):
https://fix-search-prod-build-nebari-docs.openteams-account.workers.dev

@jbouder
jbouder merged commit 0d3a5ab into main Sep 15, 2026
2 of 6 checks passed
@jbouder
jbouder deleted the fix-search-prod-build branch September 15, 2026 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant