Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
tieppt opened this issue Feb 12, 2019 · 4 comments
Closed

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

tieppt opened this issue Feb 12, 2019 · 4 comments

Comments

@tieppt
Copy link

tieppt commented Feb 12, 2019

🐞 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 #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:

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 = options.style;
}
}
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;
});
}
const styleExt = styleToFileExtention(options.style);

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;
    });
  }
@alan-agius4
Copy link
Collaborator

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 #13444

@tieppt
Copy link
Author

tieppt commented Feb 13, 2019

@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; 
}

@alan-agius4
Copy link
Collaborator

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.

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants