fix(ci): build the docs site in production mode so search works - #721
Merged
Merged
Conversation
`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>
❌ Deploy Preview for nebari-docs2 failed.
|
|
Docs preview for |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 andimport.meta.env.DEVwas true. Starlight'sSearch.astrothen renders the dev-warning branch instead of the<div id="starlight__search">container Pagefind mounts into.The chain:
bun test test— there is no separatebun run build.bun testsetsNODE_ENV=test, and child processes inherit it.test/build.test.tsrunsbun run buildinsidebeforeAll, so the site build inheritedNODE_ENV=test.wrangler deployuploads thatdist/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.Search is only available in production buildsindist/index.htmlbun run build<div class="search-container"><div id="starlight__search">NODE_ENV=test bun run buildChanges
test/build.test.ts: thebeforeAllbuild runs withNODE_ENV: 'production', so thedist/the suite produces is deployable both locally and in CI..github/workflows/docs.yml:NODE_ENV: productionon the step that builds the deployeddist/, so the value is visible where the deploy happens. (bun testrespects a presetNODE_ENVrather than overwriting it.)pages mount the search UI instead of the dev-only notice: for the home page and one page per section, the HTML must containid="starlight__search"and must not contain the dev notice. Thesearch index is generatedtest also now checkspagefind-entry.json.Verification
NODE_ENV=production SITE=https://www.nebari.dev BASE=/ bun test test(what CI runs): 6 pass, 0 fail.test: 5 pass, 1 fail — the new test, on the missingid="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