Skip to content

fix(cli): pass schemaExtraction config through to build#1002

Merged
binoy14 merged 2 commits intomainfrom
fix/build-schema-extraction
Apr 22, 2026
Merged

fix(cli): pass schemaExtraction config through to build#1002
binoy14 merged 2 commits intomainfrom
fix/build-schema-extraction

Conversation

@binoy14
Copy link
Copy Markdown
Contributor

@binoy14 binoy14 commented Apr 22, 2026

Description

The schemaExtraction config from sanity.cli.ts was not being passed through to the Vite build pipeline during sanity build (both studio and app builds). This was a gap from the CLI migration — the dev server path (sanity dev) correctly wired it through, but the build path did not.

This means users with schemaExtraction: { enabled: true } in their sanity.cli.ts would see schema extraction work during development but silently be skipped during production builds.

What to review

  • buildStaticFiles.ts — Added schemaExtraction to StaticBuildOptions and threaded it through to getViteConfig
  • buildStudio.ts — Passes cliConfig?.schemaExtraction to buildStaticFiles and logs an info message when enabled (matching old CLI behavior)
  • buildApp.ts — Same pass-through for the app build path

Testing

Existing getViteConfig tests (25/25 passing) already cover schema extraction in the Vite config layer. The fix threads the config through to that layer which was previously unreachable from the build path.

🤖 Generated with Claude Code


Note

Low Risk
Small, additive wiring/logging change that only affects builds when schemaExtraction is configured and enabled.

Overview
sanity build now threads schemaExtraction from sanity.cli.ts through the production build pipeline so schema extraction is applied during Studio and App builds.

This adds schemaExtraction to buildStaticFiles options (and forwards it to getViteConfig), passes the config from both buildStudio and buildApp, and logs an info message when schema extraction is enabled. A patch changeset is included.

Reviewed by Cursor Bugbot for commit 4f5ef6c. Bugbot is set up for automated code reviews on this repo. Configure here.

binoy14 and others added 2 commits April 22, 2026 11:37
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@claude
Copy link
Copy Markdown

claude Bot commented Apr 22, 2026

Claude finished @binoy14's task in 1m 32s —— View job


Review

  • Read changed files
  • Review diff
  • Check changeset
  • Post review feedback

Missing log message in buildApp.ts

buildStudio.ts logs an info message when schema extraction is enabled (line 171–173), but buildApp.ts does not. Per the PR description, the app build path was meant to have the same treatment. Users running sanity build for an app with schemaExtraction.enabled will get no indication that it's active, unlike both the dev server path and the studio build path.

Fix this →


Changeset

Bump type (patch) and summary are appropriate.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 22, 2026

📦 Bundle Stats — @sanity/cli

Compared against main (09f6d9e6)

@sanity/cli

Metric Value vs main (09f6d9e)
Internal (raw) 2.1 KB -
Internal (gzip) 799 B -
Bundled (raw) 10.94 MB -
Bundled (gzip) 2.05 MB -
Import time 854ms -2ms, -0.2%

bin:sanity

Metric Value vs main (09f6d9e)
Internal (raw) 975 B -
Internal (gzip) 460 B -
Bundled (raw) 9.84 MB -
Bundled (gzip) 1.77 MB -
Import time 2.03s -3ms, -0.1%

🗺️ View treemap · Artifacts

Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

📦 Bundle Stats — @sanity/cli-core

Compared against main (09f6d9e6)

Metric Value vs main (09f6d9e)
Internal (raw) 93.8 KB -
Internal (gzip) 21.9 KB -
Bundled (raw) 21.62 MB -
Bundled (gzip) 3.42 MB -
Import time 797ms -13ms, -1.6%

🗺️ View treemap · Artifacts

Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

📦 Bundle Stats — create-sanity

Compared against main (09f6d9e6)

Metric Value vs main (09f6d9e)
Internal (raw) 976 B -
Internal (gzip) 507 B -
Bundled (raw) 50.7 KB -
Bundled (gzip) 12.6 KB -
Import time ❌ ChildProcess denied: node -
Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

@github-actions
Copy link
Copy Markdown
Contributor

Coverage Delta

File Statements
packages/@sanity/cli/src/actions/build/buildApp.ts 94.9% (±0%)
packages/@sanity/cli/src/actions/build/buildStaticFiles.ts 96.5% (±0%)
packages/@sanity/cli/src/actions/build/buildStudio.ts 96.3% (- 1.2%)

Comparing 3 changed files against main @ 09f6d9e6cdf9df38e091363e4e342571cfcdf724

Overall Coverage

Metric Coverage
Statements 84.0% (±0%)
Branches 73.7% (- 0.0%)
Functions 83.9% (±0%)
Lines 84.4% (±0%)

@binoy14 binoy14 marked this pull request as ready for review April 22, 2026 15:50
@binoy14 binoy14 requested a review from a team as a code owner April 22, 2026 15:50
@binoy14 binoy14 requested review from joshuaellis and kbrabrand and removed request for a team April 22, 2026 15:50
@binoy14 binoy14 merged commit 2fd358f into main Apr 22, 2026
54 of 55 checks passed
@binoy14 binoy14 deleted the fix/build-schema-extraction branch April 22, 2026 16:17
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.

2 participants