Naming imported scss files .scss or .css.scss

◇◆丶佛笑我妖孽 提交于 2019-12-19 07:56:15

问题


I was trying to get livereload working with rails 3.2, and I came across this question, of which there is a reference to not naming imported sass partials with .css.scss:

Rails: Use livereload with Asset Pipeline

Is this correct that imported SCSS files should be named file.scss and not file.css.scss?


回答1:


Honestly, I don't think it matters much. As a convention, I generally name files that will eventually be output as an actual CSS file as .css.scss and imported files as .scss.

I do the same for .html.haml and .haml for partials.




回答2:


If you want to include .scss file from different directory/folder in your project, you need to add underscore before the filename. For example:

//files to include
yourproject/sass/partials/_navbar.scss
yourproject/sass/partials/_footer.scss

//Main style.css
yourproject/sass/style.scss

  @include "partials/navbar"
  @include "partials/footer"

If you notice, when the .scss files were imported in the main style.scss underscores were removed. The purpose of underscore is to exclude all .scss/.sass files not to be compiled unless if it is imported in a single .scss file.



来源:https://stackoverflow.com/questions/12334515/naming-imported-scss-files-scss-or-css-scss

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!