Angular7:如何使用全局文件替换

Angular 7: How to use fileReplacement globaly

我正在使用 Angular 7,我想知道是否存在任何方式来替换文件,无论使用 fileReplacement 的环境如何。是这样的: 现在的问题是我们正在使用标准方法,并且我们强制在每个环境中复制替换的文件。

    "configurations": {
      "production": {
        "fileReplacements": [
          {
             "replace": "src/app/modules/corporate/MainFooter/main-footer-container/socialmedia/styles/socialmedia.style.scss",
                  "with": "src/app/modules/corporate/MainFooter/main-footer-container/socialmedia/styles/socialmedia.inline.style.scss"
          }
        ],
      },
"stage": {
        "fileReplacements": [
          {
             "replace": "src/app/modules/corporate/MainFooter/main-footer-container/socialmedia/styles/socialmedia.style.scss",
                  "with": "src/app/modules/corporate/MainFooter/main-footer-container/socialmedia/styles/socialmedia.inline.style.scss"
          }
        ],
      },
"dev": {
        "fileReplacements": [
          {
             "replace": "src/app/modules/corporate/MainFooter/main-footer-container/socialmedia/styles/socialmedia.style.scss",
                  "with": "src/app/modules/corporate/MainFooter/main-footer-container/socialmedia/styles/socialmedia.inline.style.scss"
          }
        ],
      }
    }

有什么更好的方法吗?

谢谢!

暂不支持,9.x版本将支持多种配置。

到时候你就可以像这样配置了

{
  "configurations": {
    "production": {...},
    "stage": {...},
    "dev": {...},
    "replaceStyles": {
      "fileReplacements": [
        {
          "replace": "src/app/modules/corporate/MainFooter/main-footer-container/socialmedia/styles/socialmedia.style.scss",
          "with": "src/app/modules/corporate/MainFooter/main-footer-container/socialmedia/styles/socialmedia.inline.style.scss"
        }
      ]
    }
  }
}
$ ng build --configuration=production, replaceStyles
$ ng build --configuration=stage, replaceStyles
$ ng build --configuration=dev, replaceStyles

https://github.com/angular/angular-cli/issues/10612

https://github.com/angular/angular-cli/pull/15819