<p>angular-cli 11 的 scss 源映射仅显示 angular.json 中列出的文件</p>

创建于 2020-11-30  ·  1评论  ·  资料来源: angular/angular-cli

🐞 错误报告

命令(用x标记)


  • [ ] 新的
  • [x] 构建
  • [x] 发球
  • [ ] 测试
  • [ ] e2e
  • [ ] 产生
  • [ ] 添加
  • [ ] 更新
  • [ ] 绒毛
  • [] 提取-i18n
  • [ ] 跑
  • [ ] 配置
  • [ ] 帮助
  • [ ] 版本
  • [ ] 文档

这是回归吗?

angular cli 11 工作之前的任何版本。

描述

我有几个站点使用 angular,在 angular 11 之前,这些站点是带有后端的复杂站点。 所以我使用ng build --watch --source-map --named-chunks来开发网站,一切都很好,但是在我升级到 angular 11 之后,我所有的 scss 源映射都是错误的,我的网站使用了 bootstrap 的 scss,在升级之前,每个项目都可以显示准确的任何 css 规则的来源。 但升级后,所有规则都来自 angular.json 中列出的同一个 scss 文件。

我已经搜索了问题,似乎没有人遇到我的问题?

这是我的 angular.json

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "cbp": {
      "projectType": "application",
      "schematics": {
        "@schematics/angular:component": {
          "style": "scss"
        },
        "@schematics/angular:application": {
          "strict": true
        }
      },
      "root": "",
      "sourceRoot": "resources/src",
      "prefix": "app",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "public/bundles",
            "deployUrl": "bundles/",
            "index": "resources/src/index.html",
            "main": "resources/src/main.ts",
            "polyfills": "resources/src/polyfills.ts",
            "tsConfig": "tsconfig.app.json",
            "aot": true,
            "sourceMap": true,
            "assets": [
              "resources/src/favicon.ico",
              "resources/src/assets"
            ],
            "styles": [
              "resources/sass/style.scss",
              "resources/src/styles.scss"
            ],
            "scripts": []
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "resources/src/environments/environment.ts",
                  "with": "resources/src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": true,
              "namedChunks": false,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "500kb",
                  "maximumError": "1mb"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "2kb",
                  "maximumError": "4kb"
                }
              ]
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "cbp:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "cbp:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "cbp:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "resources/src/test.ts",
            "polyfills": "resources/src/polyfills.ts",
            "tsConfig": "tsconfig.spec.json",
            "karmaConfig": "karma.conf.js",
            "assets": [
              "resources/src/favicon.ico",
              "resources/src/assets"
            ],
            "styles": [
              "resources/src/styles.scss"
            ],
            "scripts": []
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "tsconfig.app.json",
              "tsconfig.spec.json",
              "e2e/tsconfig.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        },
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "e2e/protractor.conf.js",
            "devServerTarget": "cbp:serve"
          },
          "configurations": {
            "production": {
              "devServerTarget": "cbp:serve:production"
            }
          }
        }
      }
    }
  },
  "defaultProject": "cbp"
}

这是我的问题,所有 css 规则都来自styles.scss ,这是我模板中的 scss,而不是来自 angular 的style.scss
截屏2020-11-30 11 03 09

🔬 最小化复制

ng new test-app
cd test-app
npm i -D bootstrap
// now add "node_modules/bootstrap/scss/bootstrap.scss", to styles of angular.json
ng serve
// open localhost:4200, and check, every rule related to bootstrap are all come from bootstrap.scss file

🌍 你的环境


     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 11.0.2
Node: 14.15.1
OS: darwin x64

Angular: undefined
...
Ivy Workspace: <error i="14">

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1100.2 (cli-only)
@angular-devkit/core         11.0.2 (cli-only)
@angular-devkit/schematics   11.0.2 (cli-only)
@schematics/angular          11.0.2 (cli-only)
@schematics/update           0.1100.2 (cli-only)
webpack                      5.9.0
</error>
devkibuild-angular browser medium regression bufix

最有用的评论

截屏2020-11-30 11 28 41

最小测试用例结果

在 angular.json 中使用--sourceMap --source-map或设置sourceMap: true区别,所有三种方法都会导致完全相同的结果显示如上。

>所有评论

截屏2020-11-30 11 28 41

最小测试用例结果

在 angular.json 中使用--sourceMap --source-map或设置sourceMap: true区别,所有三种方法都会导致完全相同的结果显示如上。

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

sysmat picture sysmat  ·  3评论

delasteve picture delasteve  ·  3评论

NCC1701M picture NCC1701M  ·  3评论

gotschmarcel picture gotschmarcel  ·  3评论

IngvarKofoed picture IngvarKofoed  ·  3评论