I have been fighting with this same problem for a while and they all seem to resolve it through the imports .
That is, within the style of a component, you should do:
// Archivo: prueba.component.styl
@import '../estilos/comunes/colores'
p
color color-azul-electrico // Definido dentro del archivo colores.
However, this solution, apart from not being as nice as you expect, has some annoying problems: Every time you want to move the location of the styles of your components or your general styles, if your IDE does not manage, you'll have to update all the imports.
To avoid this, and in the meantime save a few characters, you can place the following in the .angular-cli.json
file, inside the apps object:
"stylePreprocessorOptions": {
"includePaths": [
"estilos/comunes"
]
},
Now, all the files that are inside that comunes
folder you can import them within the styles of your components in this way:
// Archivo: prueba.component.styl
@import 'colores' // Sigue el import... Pero al menos más cortito.
p
color color-azul-electrico
Anyway, if you want to use a path related to your global styles, you can continue doing it.
Note : This use%% co solution works only with SASS and STYLUS style preprocessors. >
It seems that there is still no better solution until now ...