如何通过Grunt阻止Compass输出.sass-cache文件夹

3
我有一个正在自动生成的.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正在做的事情以及我的一些任务代码片段:
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个回答

5

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

asset_cache_buster = :none
cache = false

如果那不起作用,你可以运行一个clean命令来删除该文件夹。(请参见链接) https://github.com/gruntjs/grunt-contrib-compass#clean

还是不行。我甚至在终端中尝试了 grunt compass clean,但它仍会生成 .sass-cache 文件夹。我还尝试将 compass-clean 添加为任务,但似乎没有起作用。显然我做错了什么。我还确保杀死终端任务并重新启动以确保更改生效。 - user4324916

1
如果你正在命令行中运行Sass,可以添加--no-cache标志: sass --no-cache input.scss output.css

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接