Grunt手表需要很长时间才能识别出变化

时间:2014-10-22 08:18:40

标签: performance gruntjs

我正在处理一些sass项目,而grunt文件看起来像这样

module.exports = function(grunt) {

// Project configuration.
grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    sass: {
        dist: {
            options: {
                style: 'compressed'
            },
            files: {
                'public/css/all.css': 'public/css/all.scss'
            }
        },
        dev: {
            files: {
                'public/css/all.css': 'public/css/all.scss'
            }
        }
    },
    concat: {
        js: {
            src: [
                'public/js/foot-*.js'
            ],
            dest: 'public/js/foot.js'
        }
    },
    uglify: {
        uglifyjs: {
            options: {
                mangle: false,
                compress: {
                    global_defs: {
                        "DEBUG": false
                    },
                    dead_code: true
                }
            },
            files: {
                'public/js/foot.js': ['public/js/foot.js']
            }
        }
    },
    po2mo: {
        files: {
            src: 'module/frontend/Application/language/*.po',
            expand: true
        }
    },
    watch: {
        options: {
            debounceDelay: 0,
            spawn: false
        },
        js:{
            files: ['public/js/**/foot-*-*.js', 'public/js/**/foot-1-jquery*.js'],
            tasks: ['concat:js']
        },
        css:{
            files: ['public/css/**/*.scss'],
            tasks: ['sass:dev']
        }
    },
    concurrent: {
        options: {
            logConcurrentOutput: true
        },
        watch: {
            tasks: ["watch:js","watch:css"]
        }
    }
});

grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch'); // not a default task
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-po2mo');

grunt.registerTask('default', ['sass:dev','concat:js','po2mo']);
grunt.registerTask('prod', ['sass:dist','concat:js','uglify:uglifyjs', 'po2mo']);
grunt.registerTask('watcher', ['default','concurrent:watch']); // we don't have po2mo watcher yet

};

各行是:

watch: {
        options: {
            debounceDelay: 0,
            spawn: false
        },
        js:{
            files: ['public/js/**/foot-*-*.js', 'public/js/**/foot-1-jquery*.js'],
            tasks: ['concat:js']
        },
        css:{
            files: ['public/css/**/*.scss'],
            tasks: ['sass:dev']
        }
    },

但是咕噜咕噜的守望者需要花费大量时间来识别变化。我首先分享了整个代码,看看是否有人可以帮我快速解决问题?

我是Sass的新手但是已经做了很长一段时间了。不知道为什么sass这么慢。我很确定问题出在grunt文件中。

感谢您的帮助:)

0 个答案:

没有答案