3

i have a common SCSS mixin function in global SCSS file. but i could not able to access that mixin function inside the angular2 components.

i have global style.scss which have following mixin function

@mixin respond-to($breakpoint) {
  @if $breakpoint == "small" {
    @media (max-width: 767px) {
      @content;
    }
  }
  @else if $breakpoint == "medium" {
    @media (min-width: 992px) {
      @content;
    }
  }
  @else if $breakpoint == "large" {
    @media (min-width: 1200px) {
      @content;
    }
  }
}

i am trying to access this mixin function in component.scss like

.procard{
width:50%;
 @include respond-to(small){ 
  .pro-card{
    width: 100%;
    .pro-box{
      max-width: 320px;
      margin:0 auto;
     }
   }
 } 
}

While running this it show error

enter image description here

Maheswaran S
  • 525
  • 3
  • 12

2 Answers2

0

You need to Import the Mixin lib into all your component .scss files, where you want to use them. phpStorm will still say, that he cant find this mixin, but compiler will find it.

Ricardo Rocha
  • 14,612
  • 20
  • 74
  • 130
Budi
  • 678
  • 2
  • 6
  • 27
0

you can explicitly import the global scss. OR a better way is to use the sass-resources-loader which helps you using shared scss among components without having to explicit importing them. Something like:

{ test: /\.scss$/, loader: ["raw-loader", "sass-loader", { loader: 'sass-resources-loader', options: { resources: ['./styles/global/_vars.scss', './styles/global/_mixins.scss'] }, } ] }

LeOn - Han Li
  • 9,388
  • 1
  • 65
  • 59