question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Flag to remove css files when generating component!

See original GitHub issue

Sorry for Duplicating but had no choice


I’m submitting an Advancement

Like many others i am a fan of global styles (ofcourse, if used correctly like BEMIT and i basically (quite surely like many others) don’t like this below thing for my css unless needed

h3[_ngcontent-c0] {
  margin-top: 1rem;
  color: #0277bd;
}

I will instead use global styles by either using styles.css global file or using sass tools for my css so i basically delete my foo.component.css file and its declaration from a foo component and do it like this

.c-foo--title {
  margin-top: 1rem;
  color: #0277bd;
}

In short, just would like to separate my styling with Javascript and the HTML DOM!

So just want to know if is there any way (and if not can it be provided) to have a flag on not adding separate component styling css file when we generate a component from CLI!

Something like

$ ng g c --nocss foo

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

  • Angular version: 4.0.X
  • Language: TypeScript X.X

  • Tool: CLI

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
grizzm0commented, Apr 9, 2017

I’m not sure if there’s a way to completely skip style generation, but you can pass --inline-style or --is to prevent the file from being generated. This will instead create a style key in the component annotation.

You can make this the default behaviour by changing angular-cli.json. See: https://github.com/angular/angular-cli/blob/master/packages/%40angular/cli/lib/config/schema.json

2reactions
sumitaroracommented, Apr 10, 2017

Closing as above.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it possible to build separate CSS file with angular-cli?
As @Rob correctly pointed out you can use flag --extract-css . Unfortunately this flag is not possible to use with ng-serve from Angular...
Read more >
4 Ways to Remove Unused CSS - Bits and Pieces
CSS files can easily gain redundant KBs over time. ... (as pointed to by the — content flag) and remove all unused CSS...
Read more >
Component styles
When you use the Angular CLI command ng generate component without the --inline-style flag, it creates an empty styles file for you and...
Read more >
Component Styles - Angular
The Angular CLI command ng generate component defines an empty styles array when you create the component with the --inline-style flag. ````ng ...
Read more >
Add Feature Flags to Your Angular App in 10 Minutes
component.html file. It contains some placeholder HTML and CSS you'll remove shortly and put in some of your own logic. But it's important...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found