My plan was to use the NgRx related modules (store, effects, devtools, etc.) in a library module, not in the app-module.
The NgRx related modules are imported into the libs/.../shell-module, which in turn is imported into the app-module.
I would like to provide the environment.production variable in my libs, but I have no idea how to get it in the shell-module without using a relative/absolute import path.
libs/.../shell.module.ts:
import { environment } from '../../../../../../../apps/test-app/src/environments/environment';
imports:[
...
!environment.production ? StoreDevtoolsModule.instrument() : []
...
]
Is it not possible to resolve the environment.production variable in an Angular module?
I know how to inject stuff into components, but how do you inject it into modules?
The .forRoot() config trick didn't work, because the imports array in the module decorator is out of scope of the module class.
is there another way to do this without tight coupling the environment.ts file and my libs modules?
Defining an '@' path for environment.ts in tsconfig.json, and then importing it into the module still counts as tight coupling ... right?
for this I'd generally recommend moving the environment configuration down into a library as well.
For example, you may have libs/shared/env/environment.*.ts, or libs/domain/env/environment.*.ts. You'll need to update the build steps for your app to ensure that fileReplacements is setup to handle these. Then in your app you can use import {environment} from '@company/shared/eng'.
This would look a little different if using buildable libs, since you'd want to handle the fileReplacements in the libraries build definition.