ng g c generates scss.
ng g c generates css.
npx create-nx-workspace@latest with the SASS option.ng g c at the root of workspace.generated package.json:
{
"name": "dob",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"nx": "nx",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "nx workspace-lint && ng lint",
"e2e": "ng e2e",
"affected:apps": "nx affected:apps",
"affected:libs": "nx affected:libs",
"affected:build": "nx affected:build",
"affected:e2e": "nx affected:e2e",
"affected:test": "nx affected:test",
"affected:lint": "nx affected:lint",
"affected:dep-graph": "nx affected:dep-graph",
"affected": "nx affected",
"format": "nx format:write",
"format:write": "nx format:write",
"format:check": "nx format:check",
"update": "ng update @nrwl/workspace",
"workspace-schematic": "nx workspace-schematic",
"dep-graph": "nx dep-graph",
"help": "nx help",
"postinstall": "ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points"
},
"private": true,
"dependencies": {
"@nrwl/angular": "9.2.3",
"@angular/animations": "^9.1.0",
"@angular/common": "^9.1.0",
"@angular/compiler": "^9.1.0",
"@angular/core": "^9.1.0",
"@angular/forms": "^9.1.0",
"@angular/platform-browser": "^9.1.0",
"@angular/platform-browser-dynamic": "^9.1.0",
"@angular/router": "^9.1.0",
"core-js": "^2.5.4",
"rxjs": "~6.5.4",
"zone.js": "^0.10.2",
"@nestjs/common": "^6.8.3",
"@nestjs/core": "^6.8.3",
"@nestjs/platform-express": "^6.8.3",
"reflect-metadata": "^0.1.13"
},
"devDependencies": {
"@angular/cli": "9.1.0",
"@nrwl/workspace": "9.2.3",
"@types/node": "~8.9.4",
"dotenv": "6.2.0",
"ts-node": "~7.0.0",
"tslint": "~6.0.0",
"eslint": "6.8.0",
"typescript": "~3.8.3",
"prettier": "1.19.1",
"@nrwl/nest": "9.2.3",
"@angular/compiler-cli": "^9.1.0",
"@angular/language-service": "^9.1.0",
"@angular-devkit/build-angular": "0.901.0",
"codelyzer": "~5.0.1",
"jest-preset-angular": "8.1.2",
"@nrwl/jest": "9.2.3",
"jest": "25.2.3",
"@types/jest": "25.1.4",
"ts-jest": "25.2.1",
"cypress": "^4.1.0",
"@nrwl/cypress": "9.2.3",
"@nrwl/node": "9.2.3",
"@nestjs/schematics": "^6.7.0",
"@nestjs/testing": "^6.8.3"
}
}
generated angular.json:
{
"version": 1,
"projects": {
"app": {
"projectType": "application",
"schematics": {
"@nrwl/angular:component": {
"style": "scss"
}
},
"root": "apps/app",
"sourceRoot": "apps/app/src",
"prefix": "dob",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/apps/app",
"index": "apps/app/src/index.html",
"main": "apps/app/src/main.ts",
"polyfills": "apps/app/src/polyfills.ts",
"tsConfig": "apps/app/tsconfig.app.json",
"aot": true,
"assets": ["apps/app/src/favicon.ico", "apps/app/src/assets"],
"styles": ["apps/app/src/styles.scss"],
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "apps/app/src/environments/environment.ts",
"with": "apps/app/src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "app:build",
"proxyConfig": "apps/app/proxy.conf.json"
},
"configurations": {
"production": {
"browserTarget": "app:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "app:build"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"apps/app/tsconfig.app.json",
"apps/app/tsconfig.spec.json"
],
"exclude": ["**/node_modules/**", "!apps/app/**"]
}
},
"test": {
"builder": "@nrwl/jest:jest",
"options": {
"jestConfig": "apps/app/jest.config.js",
"tsConfig": "apps/app/tsconfig.spec.json",
"passWithNoTests": true,
"setupFile": "apps/app/src/test-setup.ts"
}
}
}
},
"app-e2e": {
"root": "apps/app-e2e",
"sourceRoot": "apps/app-e2e/src",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@nrwl/cypress:cypress",
"options": {
"cypressConfig": "apps/app-e2e/cypress.json",
"tsConfig": "apps/app-e2e/tsconfig.e2e.json",
"devServerTarget": "app:serve"
},
"configurations": {
"production": {
"devServerTarget": "app:serve:production"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["apps/app-e2e/tsconfig.e2e.json"],
"exclude": ["**/node_modules/**", "!apps/app-e2e/**"]
}
}
}
},
"api": {
"root": "apps/api",
"sourceRoot": "apps/api/src",
"projectType": "application",
"prefix": "api",
"schematics": {},
"architect": {
"build": {
"builder": "@nrwl/node:build",
"options": {
"outputPath": "dist/apps/api",
"main": "apps/api/src/main.ts",
"tsConfig": "apps/api/tsconfig.app.json",
"assets": ["apps/api/src/assets"]
},
"configurations": {
"production": {
"optimization": true,
"extractLicenses": true,
"inspect": false,
"fileReplacements": [
{
"replace": "apps/api/src/environments/environment.ts",
"with": "apps/api/src/environments/environment.prod.ts"
}
]
}
}
},
"serve": {
"builder": "@nrwl/node:execute",
"options": {
"buildTarget": "api:build"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"apps/api/tsconfig.app.json",
"apps/api/tsconfig.spec.json"
],
"exclude": ["**/node_modules/**", "!apps/api/**"]
}
},
"test": {
"builder": "@nrwl/jest:jest",
"options": {
"jestConfig": "apps/api/jest.config.js",
"tsConfig": "apps/api/tsconfig.spec.json",
"passWithNoTests": true
}
}
}
},
"api-interfaces": {
"root": "libs/api-interfaces",
"sourceRoot": "libs/api-interfaces/src",
"projectType": "library",
"schematics": {},
"architect": {
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"libs/api-interfaces/tsconfig.lib.json",
"libs/api-interfaces/tsconfig.spec.json"
],
"exclude": ["**/node_modules/**", "!libs/api-interfaces/**"]
}
},
"test": {
"builder": "@nrwl/jest:jest",
"options": {
"jestConfig": "libs/api-interfaces/jest.config.js",
"tsConfig": "libs/api-interfaces/tsconfig.spec.json",
"passWithNoTests": true
}
}
}
}
},
"cli": {
"defaultCollection": "@nrwl/angular"
},
"schematics": {
"@nrwl/angular:application": {
"unitTestRunner": "jest",
"e2eTestRunner": "cypress"
},
"@nrwl/angular:library": {
"unitTestRunner": "jest"
}
},
"defaultProject": "app"
}
nx report:
@nrwl/angular : 9.2.3
@nrwl/cli : 9.2.3
@nrwl/cypress : 9.2.3
@nrwl/eslint-plugin-nx : Not Found
@nrwl/express : Not Found
@nrwl/jest : 9.2.3
@nrwl/linter : 9.2.3
@nrwl/nest : 9.2.3
@nrwl/next : Not Found
@nrwl/node : 9.2.3
@nrwl/react : Not Found
@nrwl/schematics : Not Found
@nrwl/tao : 9.2.3
@nrwl/web : Not Found
@nrwl/workspace : 9.2.3
typescript : 3.8.3
This is already a long lasting bug. The solution to it would be adding this to the default config when creating a new project.
So in the root schematics property in angular.json adding this.
"schematics": {
"@schematics/angular:component": {
"style": "scss"
}
}
Or you can do it manually of course
npx ng config schematics.@schematics/angular:component.style scss
@maartentibau
I am using the latest version.
It was already added like that.
projectType": "application",
"schematics": {
"@nrwl/angular:component": {
"style": "scss"
}
},
nx g c modules/main/launches/launches --flat --dry-run
CREATE apps/fsx-spacex/src/app/modules/main/launches/launches.component.css (0 bytes)
CREATE apps/fsx-spacex/src/app/modules/main/launches/launches.component.html (23 bytes)
CREATE apps/fsx-spacex/src/app/modules/main/launches/launches.component.spec.ts (642 bytes)
CREATE apps/fsx-spacex/src/app/modules/main/launches/launches.component.ts (290 bytes)
UPDATE apps/fsx-spacex/src/app/modules/main/launches/launches.module.ts (363 bytes)
It only works with this manual typing.
npx ng config schematics.@schematics/angular:component.style scss
@curiouscod3 this is not really doing anything @nrwl/angular:component does not seem to control the type of style extension when you run the ng g c foo-component
It only works when running the config command which adds the part that I mentioned in my previous comment. That will make it work properly as far as I know.
Fixed it here: https://github.com/nrwl/nx/pull/3653
We will release 9x and 10x releases next week. The fix will be in both. For now, you will have to manually update the collection in angular.json.
Thank you!
Most helpful comment
Fixed it here: https://github.com/nrwl/nx/pull/3653
We will release 9x and 10x releases next week. The fix will be in both. For now, you will have to manually update the collection in angular.json.
Thank you!