Include `.scss` file in another `.scss` file?

前端 未结 4 591
花落未央
花落未央 2020-12-16 11:04

How can I Include .scss file in another .scss file? I was trying to write this in a file: app.scss:

@include(\'buttons\');
@include         


        
4条回答
  •  没有蜡笔的小新
    2020-12-16 11:22

    You can use @use rule for it. This rule loads another Sass file as a module, which means you can refer to its variables, mixins, and functions in your Sass file with a namespace based on the filename. Using a file will also include the CSS it generates in your compiled output!

    // _base.scss
    $font-stack:    Helvetica, sans-serif;
    $primary-color: #333;
    
    body {
      font: 100% $font-stack;
      color: $primary-color;
    }
    

    see how to using @use 'base'; in the styles.scss file

    // styles.scss
    @use 'base';
    
    .inverse {
      background-color: base.$primary-color;
      color: white;
    }
    

    you don't need to include the file extension.

提交回复
热议问题