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

Set the environment with--configuration option #45

Closed
mhkolk opened this issue Jun 8, 2023 · 5 comments
Closed

Set the environment with--configuration option #45

mhkolk opened this issue Jun 8, 2023 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@mhkolk
Copy link

mhkolk commented Jun 8, 2023

The extension/CLI is not picking up .env files for example .env.production (present in the same dir as package.json) with NG_APP_ENV being undefined even though valid Angular configuration was provided through ng build.

PS C:\Git\myproj> ng build --configuration production
------- @ngx-env/builder -------

  • Verbose: true
  • Prefix: NG_APP
  • Working directory: C:\Git\myproj
  • Environment files:
    ✔ C:\Git\myproj.env
  • Injected keys:
    ✔ NG_APP_ENV => undefined
    ✔ NG_APP_API_FQDN
    ✔ NG_APP_API_URL

None of the default (development, production) files are being picked up, it only detects .env and .env.local (if I place it in the same dir).

@chihab
Copy link
Owner

chihab commented Jun 8, 2023

Could you try this?

NG_APP_ENV=production ng build

It should pick .env.production and .env if present

@mhkolk
Copy link
Author

mhkolk commented Jun 13, 2023

This worked though I had to use different syntax (Windows).

$env:NG_APP_ENV='production'

However I can't do this for example

"build:dev": "$env:NG_APP_ENV='k8s-dev'; ng build --configuration k8s-dev",

results in

The filename, directory name, or volume label syntax is incorrect

Why wouldn't be providing configuration with the --configuration option enough?

@chihab
Copy link
Owner

chihab commented Jun 23, 2023

maybe you'd want to use cross-env package to set the environment variable.

start: cross-env NG_APP_ENV=k8s-dev ng build --configuration k8s-dev

Your other suggestion to set NG_APP_ENV to the configuration option (when not set via NODE_ENV/NG_APP_ENV) is also interesting, thinking about it.

@chihab chihab self-assigned this Jun 23, 2023
@chihab chihab added the enhancement New feature or request label Aug 22, 2023
@LunaSquee
Copy link

LunaSquee commented Sep 29, 2023

I intuitively assumed that this environment would be set if I used the --configuration option, but I guess not 😅 Please do consider this as an option. This package would be a good replacement for the built-in file replacements with minimal effort if this was the default behavior, in my opinion.

@chihab chihab changed the title Not picking up .env files Used the --configuration option Jan 8, 2024
@chihab chihab changed the title Used the --configuration option Set the environment with--configuration option Jan 8, 2024
@chihab
Copy link
Owner

chihab commented Jan 10, 2024

Available in @ngx-env/builder 17.0.6

@chihab chihab closed this as completed Jan 10, 2024
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

3 participants