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

Add import.meta.envName for build EnvName #3041

Open
1 task
maximepvrt opened this issue Jan 27, 2025 · 1 comment
Open
1 task

Add import.meta.envName for build EnvName #3041

maximepvrt opened this issue Jan 27, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@maximepvrt
Copy link
Contributor

Describe the feature

Describe the feature

The current implementation of envName in Nuxt allows for custom environment names (e.g., staging) to be defined at build time, as per the documentation https://nuxt.com/docs/api/commands/build#options & https://nuxt.com/docs/getting-started/configuration#environment-overrides. However, there is no straightforward way to access this custom envName at runtime.

Proposal:
Introduce import.meta.envName to reflect the custom envName defined during the build process. By default, it would to return production, development, or test, but when a custom envName is provided, it would return the defined value (e.g., staging).

Use Cases:

  1. Styling and Customization:

    if (import.meta.envName === 'staging') {
        setLogoColor('blue');
    }
  2. Third-Party Module Configuration:

    import * as Sentry from '@sentry/browser';
    
    Sentry.init({
        dsn: 'https://example@sentry.io/12345',
        environment: import.meta.envName, // Pass environment, 'staging' for example
    });

Additional information

  • Would you be willing to help implement this feature?
@maximepvrt
Copy link
Contributor Author

linked to nuxt/nuxt#30776

@pi0 pi0 added enhancement New feature or request and removed pending triage labels Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants