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

Using global scss variables in my components styles.

Open a5hik opened this issue 10 years ago • 48 comments

angular-cli: 1.0.0-beta.6 node: 6.2.1 os: darwin x64

Hi I have bootstrap override varaibles.scss, which I want to use as a Global style for my app.

So, I depend on these variables on every component.scss I write. Is there a way I can add a global dependency of variables.scss.

Right now I do import the variables.scss manually in every scss file that require.

a5hik avatar Jun 30 '16 11:06 a5hik

I can't believe how difficult Angular makes using SASS. I'm about to switch to React/webpack

rdalfonso avatar Feb 16 '19 16:02 rdalfonso

this is ONE OF THE MOST COMMON THINGS I CAN IMAGINE. How can you get that wrong?!

also: you can make this work easily via webpack and sass-loader itself. Man it would be great if ng cli offered a way to extend the webpack conf out of the box. Like Vue does.

ManuelGraf avatar Feb 27 '19 15:02 ManuelGraf

Guys this is how sass/scss works and has nothing todo with Angular. Just import your variables and you are good to go OR use a global stylesheets file.

MickL avatar Feb 27 '19 17:02 MickL

So, in conclusion, if you @import something but you doesn't use a var or mixing of that thing you've imported, it isn't included in the final bundle, right?

futbolsalas15 avatar Mar 29 '19 16:03 futbolsalas15

Is there a way to use sass variables globally without the need to manually import in every single component? Perhaps this would be bad practice anyway as every component then has access, even if t doesn't need it...

cmacdonnacha avatar Apr 15 '19 12:04 cmacdonnacha

Do one thing. It will work. import variable.scss file in the component where you want to use variables, it will work. This is not standard, if something standard arrives, it is easily undo-able.

nikhilknoldus avatar Jun 21 '19 05:06 nikhilknoldus

What if i want separate css bundles, that i can switch at runtime, each bundle using its own _variables.scss?

batousik avatar Sep 12 '19 09:09 batousik

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.