Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Importing styles in angular.json vs importing in styles.css?

Tags:

css

angular

build

What is the difference between importing styles in angular.json and importing in styles.css?

Importing in angular.json

enter image description here

Importing in styles.css

enter image description here

Hope to have explained my question well. Thanks in advance.

like image 593
Elkin Avatar asked Mar 22 '19 23:03

Elkin


People also ask

Can we use both CSS and SCSS in Angular?

With the help of Angular CLI, you can install CSS or SCSS on your project and start working on that in a suitable way. If you are working with the CSS or SCSS in your angular project then it is very easy for you as compared to most other frameworks.

Does Angular use CSS modules?

We can use CSS Modules with Angular through postcss-modules and posthtml-css-modules. First, postcss-modules hash all the class names in the styles files in build time.

How would you implement CSS logic in an Angular application?

Angular components can be styled via global CSS the same as any other element in your application. Simply drop a `<link>` element on your page (typically in index. html) and you're good to go! However, Angular additional gives developers more options for scoping your styles.

How many ways are there to import a style sheet?

There are three ways of inserting a style sheet: External CSS. Internal CSS. Inline CSS.


1 Answers

The styles array inside of the angular.json file is used to declare global styles for a project (styles.css being one).

If you import all of your other stylesheets into styles.css (and styles.css is specified in the styles array in angular.json), you'll end up with one global, composite stylesheet.

If you put all of your stylesheets into the angular.json styles array independently (rather than importing them into styles.css), you'll end up with multiple global stylesheets.

like image 128
Darren Ruane Avatar answered Oct 05 '22 20:10

Darren Ruane