Skip to content

Warn User When Detecting Styles that may be SCSS or LESS for inline styles #8472

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

Closed
johnpapa opened this issue Nov 14, 2017 · 8 comments
Closed
Labels
feature Issue that requests a new feature

Comments

@johnpapa
Copy link
Contributor

Bug Report or Feature Request (mark with an x)

- [  ] bug report -> please search issues before submitting
- [ X ] feature request

Versions.

Angular CLI: 1.5.0
Node: 8.9.1
OS: darwin x64
macOS Sierra 10.12.6

Repro steps.

  1. run ng new foo --styles scss
  2. create a component with inline styles
  3. add scss styles to it
  4. run ng serve -o

The log given by the failure.

The styles compile as CSS, with no errors.

Desired functionality.

I would like to see angular warn when detecting SASS or LESS in inline styles and the CLI json file has SCSS or LESS identified.

as per chat with @StephenFluin

@Brocco Brocco added the feature Issue that requests a new feature label Nov 15, 2017
@johnpapa
Copy link
Contributor Author

Referencing the original issue where I requested that inline SASS be allowed #8470

@johnpapa
Copy link
Contributor Author

cc @wardbell

wardbell added a commit to IdeaBlade/angular that referenced this issue Nov 30, 2017
@wardbell
Copy link
Contributor

wardbell commented Nov 30, 2017

I don't fully understand the reasoning behind closing issue #8470 as expressed here:

Inline styles will not be rendered with a special renderer, unfortunately. It is impossible for us to know which compiler you want your inline style to use, and even so we don’t have control over how inline styles are compiled; we do not resolve their content like we do with external styles. This is a limitation of the angular compiler itself.

There are two arguments:

  1. CLI can’t know what to do
  2. Even if it could, there is no opportunity to process the styles strings.

The first argument isn't persuasive. The CL could apply the processor configured in .angular-cli.json by default and use an override prefix (e.g., ‘!scss!‘, ‘!css!‘, ‘!less!‘) where necessary. In order to not break existing apps, assume always ‘!css!’ unless there is a contrary prefix. #8470 describes such a syntax.

The second argument hinges on the assertion that the CLI does not preprocess files before the compiler sees them. Is that really true? I thought that we used webpack plugin to inline the templates and style files before the CLI saw the component source. If so, why can't it engage the styles preprocessor based on the information I mentioned in response to argument (1).

In any case, we should document that inline styles are not pre-processed by the CLI here in the wiki. See PR #8683

I have created a PR to do that in the Angular Docs as well:
angular/angular#20701

wardbell added a commit to IdeaBlade/angular-cli that referenced this issue Nov 30, 2017
… in CSS

Cannot write them in less, sass, or stylus
See issue angular#8472
@hansl
Copy link
Contributor

hansl commented Nov 30, 2017

The second argument hinges on the assertion that the CLI does not preprocess files before the compiler sees them. Is that really true?

That is correct. For inline styles, ngc reads the value and does not use the resource loader. There's no place for us to do this.

@hansl
Copy link
Contributor

hansl commented Nov 30, 2017

@johnpapa

I would like to see angular warn when detecting SASS or LESS in inline styles and the CLI json file has SCSS or LESS identified.

Considering there's no real pattern (using something fast like a regex or string search) that we can detect that would differentiate between SCSS/LESS and native CSS, it's really hard to do this and would significantly lower compilation speed. Or did you mean detect any inline style and show a warning?

wardbell added a commit to IdeaBlade/angular that referenced this issue Nov 30, 2017
Cannot write them in less, sass, or stylus
See CLI issue angular/angular-cli#8472
wardbell added a commit to IdeaBlade/angular that referenced this issue Nov 30, 2017
Cannot write them in less, sass, or stylus
See CLI issue angular/angular-cli#8472
wardbell added a commit to IdeaBlade/angular-cli that referenced this issue Nov 30, 2017
Cannot write them in less, sass, or stylus
See issue angular#8472
filipesilva pushed a commit that referenced this issue Dec 1, 2017
Cannot write them in less, sass, or stylus
See issue #8472
wardbell added a commit to IdeaBlade/angular that referenced this issue Dec 1, 2017
Cannot write them in less, sass, or stylus
See CLI issue angular/angular-cli#8472
clydin pushed a commit that referenced this issue Dec 4, 2017
Cannot write them in less, sass, or stylus
See issue #8472
IgorMinar pushed a commit to angular/angular that referenced this issue Dec 6, 2017
Cannot write them in less, sass, or stylus
See CLI issue angular/angular-cli#8472

PR Close #20701
IgorMinar pushed a commit to angular/angular that referenced this issue Dec 6, 2017
Cannot write them in less, sass, or stylus
See CLI issue angular/angular-cli#8472

PR Close #20701
@hansl hansl removed their assignment Feb 6, 2018
dond2clouds pushed a commit to d2clouds/speedray-cli that referenced this issue Apr 23, 2018
Cannot write them in less, sass, or stylus
See issue angular#8472
@jeffwhelpley
Copy link

Hmm...is there perhaps an opportunity to support sass/less for inline styles with the ivy rendering engine?

@alan-agius4
Copy link
Collaborator

Closing as this is working as intended. And showing a warning when the inline styles is no CSS is expensive and not always accurate. As we know what type of per-processor to use purely based on the file extension.

It is also highlighted in the AIO docs that inline styles need to be in css https://angular.io/guide/component-styles

@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
feature Issue that requests a new feature
Projects
None yet
Development

No branches or pull requests

6 participants