What is the best practic…

1 minute read

What is the best practice regarding relocating environment.ts to the /libs directory (enable front and back ends of a full-stack project to share env configurations)? Are there any pitfalls/reasons why nx generated separate environment files in my Angular and Nest app directories? Or were they created that way out of tradition?

Responses:

One thing last time I checked is that angular is not able to replace imports that use an alias at build time, that is typically why they are using relative paths. That being said you could have you library specific files that import and use a lib file.

There’s a section in one of my articles describing it: <https://indepth.dev/tiny-angular-application-projects-in-nx-workspaces/ https://indepth.dev/tiny-angular-application-projects-in-nx-workspaces/>

I don’t know whether we have fileReplacements for Nest builders.

Personally I would avoid doing that. A lib is 3rd part deployment.

What do you mean, ?

I still have concerns using the environment in your libs. For example if you go ahead and make your library an NPM package for 3rd party (which is the mindset I use) then have a lib for environment is just unclean. How you meant to swap the environment file of a package library

It’s meant as a workspace library, not a package library.

Updated: