2

I've recently updated from Angular 11 to Angular 12 and have got issues with parsing the CSS. I've followed each of the options from the following:

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

I've added this to my optimization within my angular.json file.

"optimization": {
   "scripts": true,
   "styles": {
      "minify": false,
      "inlineCritical": false
   },
   "fonts": true
},

I've added

"inlineStyleLanguage": "scss"

As my default style language.

And I'm still getting the following error for each of my scss files: enter image description here

I've included my angular.json file for info incase I'm missing anything:

{
  "$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"
  }
}
Scott Hunter
  • 48,888
  • 12
  • 60
  • 101
Jade
  • 335
  • 1
  • 2
  • 12
  • Does this answer your question? [You tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser after Angular 12 update](https://stackoverflow.com/questions/67607413/you-tried-to-parse-scss-with-the-standard-css-parser-try-again-with-the-postcss) – Brandon Taylor Jul 23 '21 at 16:41
  • @Brandon it doesn't unfortunately. I did linked that page in my question as I had followed all of the suggestions on that page and knew that other's probably have checked that too. – Jade Jul 26 '21 at 12:51
  • Have you tried adding an ignore pattern to the scss files in the assets directory? – Brandon Taylor Jul 26 '21 at 13:00
  • I haven't but this error isn't being generated in a scss file that resides in the assets directory, so I didn't think that would be helpful? This file resides within my app directory. – Jade Jul 26 '21 at 13:31
  • Hmm. I haven't seen this error thrown on a component's .scss file, only for files referenced in the assets directory. Is the component's .scss file importing anything from assets? – Brandon Taylor Jul 26 '21 at 13:35
  • @Brandon no it isn't – Jade Jul 26 '21 at 14:10

1 Answers1

0

If all other configuration looks correct. It's worth checking the syntax in the reported file(s) for anything strange.

I had received this error on a few files when migrating to NG11 and also removing Node-Sass from the repository. Other posts mentioned this resulting from sass files that were in assets folder, but wasn't my case.

In my case there were usages of /deep/. Dart-Sass seemed to be choking on that. Replacing that syntax with ::ng-deep resolved my problem.