angular-cli: Unknown word You tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser
π Bug report
Command (mark with an x)
- [x ] build
- [x ] serve
Is this a regression?
Yes, the previous version in which this bug was not present was: 12.0.0-rc.1Description
After upgrading my app to Angular CLI V 12, when I try to compile my Angular app it throws below error:
mixins.scss:7:10: Unknown word
You tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser
site.scss:84:1: Unknown word
You tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser
π¬ Minimal Reproduction
Upgrade any Angular app to V 12, and I believe it should have same behavior, since the only change I made in my project it upgrade to V12.
Below is my angular.json:
{
"$schema": "./node_modules/@angular-devkit/core/src/workspace/workspace-schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"Mustakbil": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"architect": {
"build": {
"builder": "ngx-build-plus:browser",
"options": {
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.app.json",
"progress": true,
"aot": true,
"polyfills": "src/polyfills.ts",
"assets": [
"src/assets",
"src/manifest.json",
"src/firebase-messaging-sw.js"
],
"styles": [
"src/assets/styles/site.scss"
],
"scripts": []
},
"configurations": {
"production": {
"optimization": {
"scripts": true,
"styles": {
"minify": true,
"inlineCritical": false
},
"fonts": true
},
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"serviceWorker": true
}
}
},
"serve": {
"builder": "ngx-build-plus:dev-server",
"options": {
"browserTarget": "Mustakbil:build"
},
"configurations": {
"production": {
"browserTarget": "Mustakbil:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "Mustakbil:build"
}
},
"test": {
"builder": "ngx-build-plus:karma",
"options": {
"main": "src/test.ts",
"karmaConfig": "./karma.conf.js",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"scripts": [],
"styles": [
],
"assets": [
"src/assets",
"src/manifest.json"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
},
"server": {
"builder": "@angular-devkit/build-angular:server",
"options": {
"outputPath": "dist-server",
"main": "src/main.server.ts",
"tsConfig": "src/tsconfig.server.json",
"sourceMap": true,
"optimization": false
},
"configurations": {
"production": {
"optimization": true,
"outputHashing": "media",
"sourceMap": false,
"namedChunks": false,
"extractLicenses": true,
"bundleDependencies": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
}
}
},
"prerender": {
"builder": "@nguniversal/builders:prerender",
"options": {
"browserTarget": "Mustakbil:build:production",
"serverTarget": "Mustakbil:server:production",
"routes": [
"/"
]
},
"configurations": {
"production": {}
}
}
}
}
},
"defaultProject": "Mustakbil",
"schematics": {
"@schematics/angular:component": {
"prefix": "app",
"styleext": "scss"
},
"@schematics/angular:directive": {
"prefix": "app"
}
}
}
π₯ Exception or Error
\assets\styles\mixins.scss:7:10: Unknown word
You tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser
\assets\styles\site.scss:84:1: Unknown word
You tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser
π Your Environment
Angular CLI: 12.0.0
Node: 14.16.0
Package Manager: npm 6.14.11
OS: win32 x64
Angular: 12.0.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, google-maps, language-service, material
... platform-browser, platform-browser-dynamic, platform-server
... pwa, router, service-worker
Package Version
----------------------------------------------------------
@angular-devkit/architect 0.1200.0
@angular-devkit/build-angular 12.0.0
@angular-devkit/core 12.0.0
@angular-devkit/schematics 12.0.0
@angular/fire 6.1.4
@nguniversal/aspnetcore-engine 12.0.0
@nguniversal/builders 12.0.0
@nguniversal/common 12.0.0
@schematics/angular 12.0.0
rxjs 6.6.7
typescript 4.2.3
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 18 (4 by maintainers)
Thank you so much @alan-agius4, In my case my
scssfiles were inassets/stylesfolder, I moved it to/src/stylesand it fixed the issue.From the reproduction, it appears that the issue is caused when
scssfiles are being copied to thedistinstead of being processed, caused by misconfiguration of the project.In the mentioned project
colors.scssis in theassets/folder, this is causing it be included in the compilation as an uncompiled asset because the build is configured to copy such files https://github.com/ryuseikurata/ng-v12-error/blob/54af1d100bd8108045416598b88ec49f68dba3dd/angular.json#L30 which is caused postcss to fail.Edit: the only correct way to solve the issue is to move any
.scssfiles fromassetsfolder so theyβre not copied todist.next message kept here for history purposes, maybe it could help anyone
I had same error message for
ng serveonly. Managed to fix it adding"buildOptimizer": falseand"optimization": falsetoarchitect.build.configurations.myServeConfiginsideangular.json. Look like this error is thrown bycssnanolib insideOptimizeCssWebpackPlugin. Probably it tries to parse styles as regular CSS instead of SCSS. This happened only to styles insideassetsfolder.