In my Angular 5 project I have a separate directory for my SASS, this has all my variables, functions, and mixins. Everything is imported in my main style.scss
@import
'abstracts/variables',
'abstracts/functions',
'abstracts/mixins';
Now from my angular component SCSS file I can import the variables and use it like so
@import '~sass/abstracts/variables';
This works great but when I want to reference a mixin that in turn calls a function - but it doesn't work.
// _variables.scss file
$text-settings: (
'xs': (
font-size: .75rem, // 12px
line-height: $base-line-height
)
);
// _functions.scss file
@function font-size($screen-size: 'base') {
@return map-get(map-get($text-settings, $screen-size), 'font-size');
}
// _mixins.scss file
@mixin font-xs {
font-size: font-size('xs');
}
In my angular component I now apply it like so
.class {
@include font-xs;
}
When I inspect element in the browser it shows
font-size: font-size('xs');
Update: Looks like this only happens when everything is split across the different files, but will work if all the required items are within the same sass file and then referenced within the angular components scss file.
Added an identical sass structure to this boilerplate project SASS project and it seems to work fine across multiple files, so it must definitely be something to do with the Angular-CLI. My version is
"@angular/cli": "^1.7.4",
"@angular/compiler-cli": "^5.2.9",
stylesfield in angular.json - jmdavalos