angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

ng new with --style=sass generates angular.json incorect infomation

Open tieppt opened this issue 7 years ago β€’ 4 comments

🐞 Bug report

Command (mark with an x)

- [x] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

Tested on version 7.3.1

Description

When generating a new app and selecting sass from the prompt, scss files are generated as this MR https://github.com/angular/angular-cli/pull/13552, but the angular.json file tries to reference style for component as sass:

"schematics": {
  "@schematics/angular:component": {
    "style": "sass"
  }
},

πŸ”¬ Minimal Reproduction

ng new app routing -> no styles -> sass

πŸ”₯ Exception or Error





🌍 Your Environment



$ ng version                                                                                     ξ‚² βœ” ξ‚² 4017 ξ‚² 23:36:56

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / β–³ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 7.3.1
Node: 10.15.0
OS: darwin x64
Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.13.1
@angular-devkit/core         7.3.1
@angular-devkit/schematics   7.3.1
@schematics/angular          7.3.1
@schematics/update           0.13.1
rxjs                         6.3.3
typescript                   3.2.4

Anything else relevant?

Update the following lines:

https://github.com/angular/angular-cli/blob/86356a747dccad75e4721a7d57e68c856a431c0b/packages/schematics/angular/application/index.ts#L164-L189

to:

  const styleExt = styleToFileExtention(options.style);
  if (options.inlineTemplate === true
    || options.inlineStyle === true
    || options.style !== Style.Css) {
    schematics['@schematics/angular:component'] = {};
    if (options.inlineTemplate === true) {
      (schematics['@schematics/angular:component'] as JsonObject).inlineTemplate = true;
    }
    if (options.inlineStyle === true) {
      (schematics['@schematics/angular:component'] as JsonObject).inlineStyle = true;
    }
    if (options.style && options.style !== Style.Css) {
      (schematics['@schematics/angular:component'] as JsonObject).style = styleExt;
    }
  }

  if (options.skipTests === true) {
    ['class', 'component', 'directive', 'guard', 'module', 'pipe', 'service'].forEach((type) => {
      if (!(`@schematics/angular:${type}` in schematics)) {
        schematics[`@schematics/angular:${type}`] = {};
      }
      (schematics[`@schematics/angular:${type}`] as JsonObject).skipTests = true;
    });
  }


tieppt avatar Feb 12 '19 16:02 tieppt

I'm sorry, but we don't understand the problem you are reporting.

The sass extension was dropped in favor of scss. Kindly see this PR https://github.com/angular/angular-cli/pull/13444

alan-agius4 avatar Feb 12 '19 18:02 alan-agius4

@alan-agius4 sorry my bad. I known we do not support .sass any more. But when we create new app and sass is selected from interactive mode, the CLI still put sass as default component style preprocessor. As expected, it should generate as following:

screen shot 2019-02-13 at 8 32 13 am

this code is not correct:

if (options.style && options.style !== Style.Css) { 
  (schematics['@schematics/angular:component'] as JsonObject).style = options.style; 
}

tieppt avatar Feb 13 '19 01:02 tieppt

Style can be both the extension of the preprocessor name. As a mater of fact we lean in favor towards the later.

So style should be sass and not scss, as the later is an extension and not a preprocessor.

alan-agius4 avatar Feb 13 '19 05:02 alan-agius4

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.