search

Home  >  Q&A  >  body text

前端 - sass 如何import单条css选择器

最近开始用sass,遇到了一个问题,看一下下面的代码

@import 'base.scss';

.btn {
  @extend reset-btn;
}

base.scss文件里面,有很多已经写好的选择器,但是,我只用到一个reset-btn,在这种情况下,我还是把整个base.scss文件里面所有的内容全部导了进来,就会有很多重复并且我用不到的代码,这种情况下,我该怎么解决呢?

PHP中文网PHP中文网2872 days ago494

reply all(2)I'll reply

  • 怪我咯

    怪我咯2017-04-17 11:41:28

    If it is a written selector
    `
    .selector {
    }
    `
    it will be used. No solution

    So the imported files are best mixedin
    or this kind of

    `
    %selector {
    }
    `

    sass virtual class form

    reply
    0
  • 怪我咯

    怪我咯2017-04-17 11:41:28

    sass will not have duplicate code. You will know after compiling it into css and taking a look. Although we may have defined many mixin, they will not be converted when they are not actually used in the project. into css, like here, the final generated css will only be reset-btn related to css

    reply
    0
  • Cancelreply