Closed davisriska closed 5 months ago
I realized that I have to define NG_APP_ENV=wateverhere for it to replace in code. For some reason I expected it to just work and take the value from --configuration or just replace it with an empty string. But I realize now it probably just goes through all available env vars and replaces them and if you have something that dosnt have the value it just leaves the import.meta.env in code.
Is this the expected behavior? As In transpile successfully with variables missing? It would be nice if it would shout warnings at you if theres no configured values.
I followed the quick start guide - https://github.com/chihab/dotenv-run/tree/main/packages/angular Installed with
ng add @ngx-env/builder
. Movedenv.d.ts
from/src
to/resources/frontend
because it wasn't respecting the configured"sourceRoot": "resources/frontend",
in angular.json. Removed the depricated process code fromenv.d.ts
because I plan on using import.meta.env method. I see that the builder was replaced in angular.json tobuilder": "@ngx-env/builder:application",
. Im running angular build withnpm run watch
which is configured asng build --watch --configuration development
. It builds fine but trying to load the angular app i get hit with the error in console -ERROR TypeError: import.meta.env is undefined
. I was trying just your sample codeAnd when I look at the generated code i see
This is what i recieve as ouput
This is what I have configured as extras in the options.
Also I do have
environments.ts files in /resources/frontend/environments and this configuration -
Should these files show up under environment files in the output?
What seems weird to me is that I saw in other issues that it outputs verbose: true if its configured and it seems I dont get that. So maybe somethings wrong with the config?
I have restarted everything, so Im pretty sure it should be running with the library. What could I have missed or what should I try to change to figure out why its not working?
Edit: After looking over the angular.json file, I changed the
root
parameter to "./", so its like thisAnd now this is the output
So I guess now it finds the .env file I have. But still it gives the same console error previously mentioned.
Edit 2: