Naming imported scss files .scss or .css.scss

2019-02-17 14:18发布

问题:

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.