Search code examples
cachingsassgruntjscompass

How do I prevent Compass from outputting .sass-cache folder using Grunt


I have a .sass-cache folder that is being auto generated. Trying to figure out how not to let it generate it at all. To be more clear, I don't want the .sass-cache folder.

I've tried several approaches but can't seem to keep it from generating.

Here's a couple approaches attempted:

  • noCache: false or true
  • config.rb file with: asset_cache_buster = :none
  • config.rb file with: cache = false

Here is what my watch is doing:

module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),

watch: {
    scripts: {
        files: ['assets/js/*.js'],
        tasks: ['concat', 'uglify', 'copy', 'clean'],
        options: {
            spawn: false
        }
    },
    scss: {
        files: ['assets/scss/*.scss'],
        tasks: ['compass', 'cssmin'],
    }
},

then later on, here is what Compass is doing & a snippet of my tasks:

compass: {
    development: {
        options: {
            config: './config.rb',
            sassDir: 'assets/scss',
            cssDir: 'assets/css'
        }
    }
},

clean:{
    build: {
    }
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.registerTask('default', ['watch']);
grunt.registerTask(
    'build',
    'Compiles all the assets and copies the files to the build directory.',
    ['less', 'compass', 'cssmin', 'concat', 'uglify', 'copy', 'clean']
);
};

here is what I'm trying in my config.

if File.file?( './.nosasscache' )
    asset_cache_buster = :none
    cache = false # Uncomment to disable cache.
end

Solution

  • Setting cache = false in your config.rb should be enough. You could try disabling all caching:

    asset_cache_buster = :none
    cache = false
    

    If that doesn't work you could always run a clean to remove the folder.(see link)

    https://github.com/gruntjs/grunt-contrib-compass#clean