【问题标题】:How do I prevent Compass from outputting .sass-cache folder using Grunt如何防止 Compass 使用 Grunt 输出 .sass-cache 文件夹
【发布时间】:2017-08-24 12:13:10
【问题描述】:

我有一个自动生成的 .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'],
    }
},

稍后,这是 Compass 正在做的事情以及我的任务的 sn-p:

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

【问题讨论】:

    标签: caching sass gruntjs compass


    【解决方案1】:

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

    asset_cache_buster = :none
    cache = false
    

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

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

    【讨论】:

    • 它仍然没有发生。我什至在终端中尝试了 grunt compass clean ,它仍然会生成 .sass-cache 文件夹。我还尝试将 compass-clean 添加为任务,但似乎不起作用。我显然没有做正确的事情。我还确定我会终止终端任务并重新启动它以确保更改生效。
    【解决方案2】:

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

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

    【讨论】:

      猜你喜欢
      • 2014-08-12
      • 1970-01-01
      • 2013-09-08
      • 2011-07-24
      • 2016-01-02
      • 1970-01-01
      • 2016-07-18
      • 2015-02-14
      相关资源
      最近更新 更多