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!

  • 2
    Welcome to [so]! Note that I added a missing `/` to the beginning your code sample. Please confirm that this matches your own code. Thanks! – jpaugh Feb 12 '18 at 21:58
  • https://github.com/angular/angular-cli/wiki/stories-application-environments – R. Richards Feb 12 '18 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 – Chitra Sharathchandra Feb 12 '18 at 22:51

1 Answers1

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

ericksoen
  • 821
  • 8
  • 14