0

我必须在整个项目中使用一些 scss 文件

"src/assets/fonts.css",
"./node_modules/bootstrap/dist/css/bootstrap.min.css",
"src/styles.scss",

所以我把这些文件加到了styles:[]里面"architect:"options":"styles":[]

以及一些特定于环境的 SCSS 文件

"src/environments/environment.scss"

或者

"src/environments/environment.brazil.scss"

"src/environments/environment.scss"再次添加到样式数组,但我在每个环境的配置对象中替换了这个文件,如下图巴西配置所示。

"architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/browser",
            "index": "src/index.html",
            "main": "src/main.ts",
            "tsConfig": "src/tsconfig.app.json",
            "polyfills": "src/polyfills.ts",
            "assets": [
              {
                "glob": "**/*",
                "input": "src/assets",
                "output": "/assets"
              },
              {
                "glob": "favicon.ico",
                "input": "src",
                "output": "/"
              }
            ],
            "styles": [
              "src/assets/fonts.css",
              "./node_modules/bootstrap/dist/css/bootstrap.min.css",
              "src/styles.scss",
              "src/environments/environment.scss"
            ],
            "scripts": [
              "src/assets/js/commonScript.js"
            ]
          },
          "configurations": {
            "alphaBrazil": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.brazil.ts"
                },
                {
                  "replace": "src/environments/environment.scss",
                  "with": "src/environments/environment.brazil.scss"
                }
              ]
            }
          }
        },

但我还是看到"src/environments/environment.scss"是用的而不是"src/environments/environment.brazil.scss"

我不明白为什么 environment.scss 没有被 environment.brazil.scss 文件取代。

4

1 回答 1

-1

在配置部分,根据我们在服务应用程序时选择的环境,它选择必须使用的替换,试试这个 ng serve --configuration=alphaBrazil

于 2019-07-24T11:28:47.053 回答