-
Notifications
You must be signed in to change notification settings - Fork 59
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: add env-flag for env-specific config (#357) #424
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Till Sanders <[email protected]>
Signed-off-by: Till Sanders <[email protected]>
Does this PR also apply for the environment overrides set in export default defineNuxtConfig({
$production: {
ignore: ['app/pages/dev'],
scripts: {
registry: {
cloudflareWebAnalytics: true,
},
},
},
$preview: {
ignore: ['app/pages/dev'],
},
}); |
src/commands/build.ts
Outdated
@@ -27,6 +27,10 @@ export default defineCommand({ | |||
type: 'string', | |||
description: 'Path to .env file', | |||
}, | |||
env: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For more clarity i would suggest to name it envName
/ --env-name
.
--env
might also be usable for other purposes in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PS: i think we can make a shared object similar to how legacyRootDirArgs
now i guess since this is arg is shared for all commands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I appreciate your feedback! I made the necessary changes as you suggested. I noticed that there is a slight inconsistency in the way the flags are named. Some use kebab-case, others lowerCamelCase – e.g. --logLevel
and --no-fork
. I decided to go with lowerCamelCase as that seems to be the majority and matches the naming in the loadNuxt()
function.
I also made a small amendment to the documentation, here: nuxt/nuxt#28909
Please let me know if any other changes are required – looking forward to have this available!
Signed-off-by: Till Sanders <[email protected]>
Documentation accompanying the PR for Nuxt CLI: nuxt/cli#424 (currently in review)
This PR is proposing to add a new
--env [name]
attribute to Nuxi. The attribute will be passed to theenvName
option of the c12 library. This adds the ability to support environment overrides (environment-specific configuration) for custom environments. Currently, c12 supports that and the types of the nuxt configuration file are aware of that, but there is no way to actually use custom environments, becauseNODE_ENV
cannot be set to values other thanproduction
ordevelopment
. This PR closes the gap, making deployments to different environments easier.See #357.
Should this be approved, I would be happy to amend the documentation accordingly.