首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >您尝试使用标准CSS解析器解析SCSS;请使用postcss-scss解析器重试

您尝试使用标准CSS解析器解析SCSS;请使用postcss-scss解析器重试
EN

Stack Overflow用户
提问于 2021-07-23 19:58:43
回答 1查看 182关注 0票数 2

我最近从Angular 11更新到Angular 12,在解析CSS时遇到了问题。我遵循了下面的每一个选项:

You tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser after Angular 12 update

我已经在angular.json文件中将其添加到我的优化中。

代码语言:javascript
复制
"optimization": {
   "scripts": true,
   "styles": {
      "minify": false,
      "inlineCritical": false
   },
   "fonts": true
},

我已经添加了

"inlineStyleLanguage": "scss"

作为我的默认风格语言。

对于我的每个scss文件,我仍然得到以下错误:

我已经包含了我的angular.json文件作为参考,以防我遗漏了什么:

代码语言:javascript
复制
{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "portal": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "app",
      "schematics": {
        "@schematics/angular:component": {
          "style": "scss"
        },
        "@schematics/angular:application": {
          "strict": true
        }
      },
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "allowedCommonJsDependencies": [
              "lodash",
              "@firebase/database",
              "angular2-chartjs",
              "@ant-design/colors",
              "@ant-design/icons-angular",
              "@ant-design/icons-angular/icons"
            ],
            "aot": true,
            "outputPath": "dist",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.app.json",
            "inlineStyleLanguage": "scss",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "./node_modules/ng-zorro-antd/style/entry.less",
              "src/app/components/kit/vendors/antd/themes/default.less",
              "src/app/components/kit/vendors/antd/themes/dark.less",
              "./node_modules/bootstrap/dist/css/bootstrap.min.css",
              "./node_modules/chartist/dist/chartist.css",
              "./node_modules/quill/dist/quill.core.css",
              "./node_modules/quill/dist/quill.bubble.css",
              "./node_modules/quill/dist/quill.snow.css",
              "./node_modules/c3/c3.min.css",
              "src/global.scss",
              "src/app/layouts/Auth/auth.component.scss"
            ],
            "scripts": [
              "./node_modules/c3/c3.min.js"
            ]
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "optimization": {
                "scripts": true,
                "styles": {
                  "minify": false,
                  "inlineCritical": false
                },
                "fonts": true
              },
              "outputHashing": "all",
              "sourceMap": false,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": false,
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "2mb",
                  "maximumError": "10mb"
                }
              ]
            },
            "hmr": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.hmr.ts"
                }
              ],
              "optimization": {
                "scripts": true,
                "styles": {
                  "minify": false,
                  "inlineCritical": false
                },
                "fonts": true
              },
              "outputHashing": "all",
              "sourceMap": false,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": false,
            },
            "demo": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.demo.ts"
                }
              ],
              "optimization": {
                "scripts": true,
                "styles": {
                  "minify": false,
                  "inlineCritical": false
                },
                "fonts": true
              },
              "outputHashing": "all",
              "sourceMap": false,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": false
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "aot": true,
            "browserTarget": "portal:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "portal:build:production"
            },
            "hmr": {
              "browserTarget": "portal:build:hmr",
              "hmr": true
            },
            "demo": {
              "browserTarget": "portal:build:demo"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "portal:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.spec.json",
            "karmaConfig": "src/karma.conf.js",
            "inlineStyleLanguage": "scss",
            "styles": [
              "src/styles.scss"
            ],
            "scripts": [],
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ]
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "src/tsconfig.app.json",
              "src/tsconfig.spec.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    },
    "portal-e2e": {
      "root": "e2e/",
      "projectType": "application",
      "prefix": "",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "e2e/protractor.conf.js",
            "devServerTarget": "portal:serve"
          },
          "configurations": {
            "production": {
              "devServerTarget": "portal:serve:production"
            }
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": "e2e/tsconfig.e2e.json",
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    }
  },
  "defaultProject": "portal",
  "cli": {
    "analytics": "c2ed9326-a5b8-4009-9392-6be3b6fcfd3c"
  }
}
EN

回答 1

Stack Overflow用户

发布于 2021-10-01 18:47:22

如果所有其他配置看起来都正确。检查报告文件中的语法是否有任何奇怪之处是值得的。

在迁移到NG11并从存储库中删除Node-Sass时,我在一些文件上收到了这个错误。其他帖子提到这是由于assets文件夹中的sass文件导致的,但不是我的情况。

在我的例子中,有/deep/的用法。达特-萨斯似乎被它卡住了。用::ng-deep替换这个语法解决了我的问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68498819

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档