如何防止 Compass 使用 Grunt 输出 .sass-cache 文件夹

3 caching sass gruntjs compass

我有一个正在自动生成的 .sass-cache 文件夹。试图弄清楚如何完全不让它产生它。更清楚地说,我不需要 .sass-cache 文件夹。

我尝试了几种方法,但似乎无法阻止它生成。

以下是尝试的几种方法:

  • noCache:假或真
  • config.rb 文件包含: asset_cache_buster = :none
  • config.rb 文件包含:cache = false

这是我的手表正在做的事情:

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'],
    }
},
Run Code Online (Sandbox Code Playgroud)

接下来,这是 Compass 正在做的事情以及我的任务片段:

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']
);
};
Run Code Online (Sandbox Code Playgroud)

这是我在配置中尝试的内容。

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

Col*_*con 5

设置cache = false在你的config.rb应该足够了。您可以尝试禁用所有缓存:

asset_cache_buster = :none
cache = false
Run Code Online (Sandbox Code Playgroud)

如果这不起作用,您可以随时运行 clean 来删除该文件夹。(请参阅链接)

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