- [x] bug report -> please search issues before submitting
- [ ] feature request
> ng --version
@angular/cli: 1.4.1
node: 6.11.3
os: linux x64
@angular/animations: 4.3.6
@angular/common: 4.3.6
@angular/compiler: 4.3.6
@angular/core: 4.3.6
@angular/forms: 4.3.6
@angular/http: 4.3.6
@angular/platform-browser: 4.3.6
@angular/platform-browser-dynamic: 4.3.6
@angular/router: 4.3.6
@angular/cli: 1.4.1
@angular/compiler-cli: 4.3.6
@angular/language-service: 4.3.6
typescript: 2.3.4
> npm --version
3.10.10
After setting the default....
> ng set --global defaults.styleExt=scss
> grep styleExt ~/angular-cli.json
"styleExt": "scss"
When I make a new project...
> ng new my_proj && cd my_proj
...
> grep styleExt ./.angular-cli.json
"styleExt": "scss",
I have a file called app.component.scss with the correct styleUrl in app.component.ts.
However, when I ng g component my-awesome-component, I end up with my-awesome.component.css and the equivalent styleUrl in the Typescript file.
I would like it to respect the settings in .angular-cli.json like ng new does.
It is not only the styleExt property, but also the prefix property which is ignored.
in my .angular-cli.json I have
{
"apps": [
{
"prefix": "ts",
}
],
"defaults": {
"styleExt": "scss",
"component": {}
}
}
"
but when generating a new component ng g +my-module/new-component I end up with a .css file instead of a .scss as already reported, but also the component selector is app-new-component instead of ts-new-component
I think that this is a serious regression compared to v1.3.2
Actually all defaults are ignored in the .angular-cli.json file. If you use the options directly in the command line everything still works file.
Same with me, I raised issue over SO for this, Here is link , https://stackoverflow.com/questions/46139997/angular-cli-1-4-1-ng-always-generate-spec-file-and-css-even-default-prefix-is
I thought , its only with me, but seems CLI team broke things very seriously here. I hope by downgrading it solve temporary.
The style extension issue was already reported here: https://github.com/angular/angular-cli/issues/7624
@Brocco I believe there is a problem with the schematics library.
I found two troublesome commits, tested with the command ng g c test:
128187e4c1b20aa5e6231099f1cb80e094a2d8d9
Problems that started here:
c doesn't work, using component does.884385e4735a74ee593cc7d510258b9aca63d4f0
c came back to lifeHope this helps! :)
Dupe of #7624
Even though this is a dupe I'm going to leave it open since #7647 will close this when it gets merged (and as of now, Travis is passing, so it just needs a review). And sorry for posting a dupe- I'm not sure how I missed 7624.
Is this _really_ still open?
This works
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"my-app": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {
"@schematics/angular:component": {
"styleext": "scss"
}
},
...
}
}
}
It's sad but on:
Angular CLI: 7.3.7
Node: 10.14.1
OS: win32 x64
Angular: 7.2.11
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router, service-worker
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.13.7
@angular-devkit/build-angular 0.13.7
@angular-devkit/build-optimizer 0.13.7
@angular-devkit/build-webpack 0.13.7
@angular-devkit/core 7.3.7
@angular-devkit/schematics 7.3.7
@angular/cdk 7.3.6
@angular/cli 7.3.7
@angular/flex-layout 7.0.0-beta.24
@angular/material 7.3.6
@angular/pwa 0.13.7
@ngtools/webpack 7.3.7
@schematics/angular 7.3.7
@schematics/update 0.13.7
rxjs 6.4.0
typescript 3.2.4
webpack 4.29.0
ng generate component is still ignoring default settings on angular.json:
"myapp": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "ids",
"schematics": {
"@schematics/angular:component": {
"inlineStyle": false,
"inlineTemplate": false,
"spec": false,
"styleext": "scss"
}
},
Actually it's only happening on "spec" and "styleext". Prefix and directories are working OK.
On Angular 8 , in my case, this issue is only happening after install @ngxs/schematics. Once this option is removed, ng g component is working fine again.
Hope this helps.
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
Actually all defaults are ignored in the
.angular-cli.jsonfile. If you use the options directly in the command line everything still works file.