0

I am in the process of developing custom schematics for our Angular Cli project. One of the requirements is to add properties/variables to the environment.prod.ts and environment.dev.ts files. I was wondering if any of you have done that and how you went about doing it. So far I have not found any way of retrieving the content of the files themselves. I have only managed to find the following:

/**
* Source file for environment config.
*/
environmentSource?: string;
/**
* Name and corresponding file for environment config.
*/
environments?: {
  [name: string]: any; // tslint:disable-line:no-any

Any help is greatly appreciated!

3
  • 2
    Welcome to Stack Overflow! Note that I added a missing / to the beginning your code sample. Please confirm that this matches your own code. Thanks! Commented Feb 12, 2018 at 21:58
  • github.com/angular/angular-cli/wiki/… Commented Feb 12, 2018 at 22:29
  • @jpaugh - this is config information available in angular schematics - I wanted to show the environment related config information currently available with schematics i.e. only file information and not content of the file Commented Feb 12, 2018 at 22:51

1 Answer 1

1

Depending on how much customization your environment.ts file requires, you might find it easier to create a static asset of your custom file and copy it into the target directory rather than try to manipulate the original file generated via the Angular CLI.

For example, in the image below, I combine the apply, url, template and move operators provided in @angular-devkit/schematic to copy some custom files to the root of my Angular application (the merge strategy will overwrite any conflicts that exist with files generated by @schematics/angular.

Schematic File Copy

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.