如何防止Compass使用Grunt

时间:2015-07-21 18:55:21

标签: caching sass gruntjs compass

我有一个自动生成的.sass-cache文件夹。试图弄清楚如何不让它产生它。为了更清楚,我不想要.sass-cache文件夹。

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

以下是一些尝试的方法:

  • noCache:false或true
  • 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'],
    }
},

然后,这就是指南针正在做的事情&我的任务片段:

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']
);
};

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

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

2 个答案:

答案 0 :(得分:3)

cache = false中设置config.rb就足够了。您可以尝试禁用所有缓存:

asset_cache_buster = :none
cache = false

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

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

答案 1 :(得分:1)

如果从命令行运行Sass,可以添加--no-cache标志:

sass --no-cache input.scss output.css

相关问题