Why does Sass cache folder get created

2019-01-21 18:14发布

问题:

I have started trying out Sass for my css work. In the directory where my Css file resides I see a '.sass-cache' folder too. Can any one tell me why is this folder created and is it safe if I delete it.

thanks,

回答1:

By default, Sass caches compiled templates and partials. This dramatically speeds up re-compilation of large collections of Sass files, and works best if the Sass templates are split up into separate files that are all @imported into one large file.

Without a framework, Sass puts the cached templates in the .sass-cache directory. In Rails and Merb, they go in tmp/sass-cache. The directory can be customized with the :cache_location option.

If you don’t want Sass to use caching at all, set the :cache option to false.

You can configure the Sass cache location by setting a Sass option in your compass configuration file like so:

sass_options = {:cache_location => "path\to\tmp\sass-cache"}

Source: Sass reference



回答2:

If your main problem is "inhibiting pushes to development environments when multiple developers use/change it", you can add it to your .gitignore file. As stated in the other answer, Sass cache files speed up compilation based on whether a Sass file has changed since last compile.

In my experience it's standard practice to consider them temporary files, and omit them from version control.



标签: sass