Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI Configuration for Typegen #7621

Open
okj579 opened this issue Oct 15, 2024 · 2 comments
Open

CLI Configuration for Typegen #7621

okj579 opened this issue Oct 15, 2024 · 2 comments
Labels

Comments

@okj579
Copy link
Contributor

okj579 commented Oct 15, 2024

Is your feature request related to a problem? Please describe.
Using Typegen across separate repositories (e.g. on for studio, one for the frontend) is difficult, as you can't mix local settings and those that are committed to the repository. The only configuration possibility at the moment is sanity-typegen.json.

Describe the solution you'd like
Configuration via CLI options and/or environment variables

Describe alternatives you've considered
I'm using an external script at the moment to gather the relevant options from constant, project and local settings, then resolve paths to be relative to the Sanity Studio root, write a temporary sanity-typegen.json, run typegen and clean up again afterwards. This is much more cumbersome than it has to be, though.

@sgulseth
Copy link
Member

sgulseth commented Nov 1, 2024

👋 We have had internal discussions around moving sanity-typegen.json config into the sanity.config.ts, as a separate object. The config would look something similar to:

import {defineConfig} from 'sanity'

export default defineConfig({
  ... // the rest of your config
  schemaExtract: {
     ...
  },
  typegen: {
    generates: 'sanity.types.ts` // or process.env.TYPEGEN_OUTPUT || 'sanity.types.ts`
  },
})

Since this all being executed then during runtime it should work by reading options from the environment.

Would this solve your use case?

@sgulseth sgulseth added the question label Nov 1, 2024 — with Linear
@okj579
Copy link
Contributor Author

okj579 commented Nov 5, 2024

Yes, I think with that I could set all relevant settings on the command line without temporary files and the like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants