指南针和手表的咕噜声编译缓慢

xph*_*ong 9 performance watch gruntjs grunt-contrib-watch grunt-contrib-compass

Grunt需要很长时间来编译css文件,我不确定这是否正常但是常规指南针需要大约5秒钟.

所以问题是如果有任何方法可以加快Grunt的编译时间,或者只是坚持使用罗盘手表?

Running "compass:dist" (compass) task
?unchanged images/sprite-sf580a96666.png
overwrite stylesheets/app.css (3.263s)
unchanged images/sprite-sf580a96666.png
overwrite stylesheets/app_fr.css (3.289s)
Compilation took 11.116s

Running "watch" task
Completed in 13.974s at Wed Dec 18 2013 13:53:05 GMT-0500 (Eastern Standard Time- Waiting...
OK
>> File "scss\_core.scss" changed.
Run Code Online (Sandbox Code Playgroud)

Gruntfile.js:

compass: {
        dist: {
            options: {
            config: 'config.rb'
            }
        }
    },

    watch: {
        sass: {
            files: ['scss/*.scss'],
            tasks: ['compass:dist'],
            options: {
                spawn: false,
            }
        },
        scripts: {
            files: ['js/*.js'],
            tasks: ['concat', 'uglify'],
            options: {
                spawn: false,
            }
        }
    }

});
Run Code Online (Sandbox Code Playgroud)

Hen*_*yth 16

除了Simon提到的关于watchgrunt-contrib-compass 的选项之外,你可以使用grunt-concurrent来有效地运行两个进程,grunt watch并且compass watch彼此并行:

concurrent: {
    watch: {
        tasks: ['watch', 'compass:watch'],
        options: {
            logConcurrentOutput: true
        }
    }
},
compass: {
    watch: {
        options: {
            watch: true
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

如果你想在构建,部署,或其他任何需要从咕噜运行指南针compile的替代watch,则需要进行第二次罗盘任务和使用:

compass: {
    // Compass grunt module requires a named target property with options.
    compile: {
        options: {}
    }
}
Run Code Online (Sandbox Code Playgroud)


Sim*_*ias 5

好吧,你可以使用Grunt-contrib-compass watch选项观看.这将产生指南针表,这样你就会有更好的表现.虽然这不允许您观看多种类型的文件(例如,如果您还注意.coffee文件或总是重建js等).

如果您绝对需要grunt-contrib-watch,请确保使用grunt任务激活sass缓存.从你在这里粘贴的配置看起来就像是.但是缓存问题通常是指南针需要很长时间才能编译的原因; 如果我是你,我会仔细查看我的Gruntfile.js.

此外,许多精灵和图像处理方法可能需要很长时间才能处理.