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

feat(cli): programmatically pass nuxt config overrides (to dev) #19371

Merged
merged 6 commits into from Mar 8, 2023

Conversation

dword-design
Copy link
Contributor

@dword-design dword-design commented Mar 1, 2023

πŸ”— Linked issue

#19347

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Allows to pass additional options to runCommand, so a Nuxt config can be passed programmatically. Resolves #19347. This isn't really a clean solution. Clean would be to have a function with the logic and the command consumes this function. The logic is also exported and someone can use it instead of the command.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly. (there is no doc)

@codesandbox
Copy link

codesandbox bot commented Mar 1, 2023

CodeSandbox logoCodeSandbox logoΒ  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@pi0
Copy link
Member

pi0 commented Mar 3, 2023

Generally love the idea (tbh always been thinking to have it). Only there is a concern about --config <path to custom config file> (mapping to configFile from c12) vs --config <config_overrides_object>.

I think we should use --config for passing path to config file.

For object passing, we might use NUXT_CUSTOM_CONFIG env variable revived by destr as it also allows passing custom config from different programmatic conditions with more flexibility. this could be a feature from unjs/c12 btw. to test properly and consistently introduce to CLis. Relavant issues:

@dword-design
Copy link
Contributor Author

@pi0 I'm not sure if passing the config via environment variables alone will be sufficient since a config can contain functions (e.g. a module imported and passed directly). I think there is no way around passing the config as a JS object directly.

@pi0
Copy link
Member

pi0 commented Mar 3, 2023

Fair enough. Only since --config as arg should be reserved for config path, i think we can workaround it slightly differently by passing custom options as second argument to the sub-commands (here) unblocking programmatic usage.

@dword-design
Copy link
Contributor Author

@pi0 yeah I linked a PR that does a similar thing (adding it to args)

packages/nuxi/src/run.ts Outdated Show resolved Hide resolved
@pi0 pi0 changed the title feat: pass nuxt config to commands feat(cli): programatically pass nuxt config to commands Mar 3, 2023
@danielroe danielroe requested a review from pi0 March 8, 2023 10:51
@danielroe danielroe mentioned this pull request Mar 8, 2023
@pi0 pi0 changed the title feat(cli): programatically pass nuxt config to commands feat(cli): programatically pass nuxt config overrides to dev command Mar 8, 2023
@danielroe danielroe changed the title feat(cli): programatically pass nuxt config overrides to dev command feat(cli): programmatically pass nuxt config overrides (to dev) Mar 8, 2023
@danielroe danielroe merged commit e344321 into nuxt:main Mar 8, 2023
@dword-design dword-design deleted the dev-config branch March 8, 2023 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Run dev server programmatically
3 participants