如何制作' grunt-watch'更新只更改文件?

时间:2014-07-17 10:38:26

标签: gruntjs

Watch工作正常但是,是否可以配置grunt-watch以便它不会循环每个正在观看的任务,因为只更改了一个文件?

对于exp我的grunt文件:

module.exports = function(grunt) {

// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),

watch: {
html: {
    files: ['styles/style.scss','styles/style.css','js/global.js','img/**/*.
    {png,jpg}'],
    tasks: ['sass', 'cssmin', 'uglify', 'imagemin']
}
},
sass: {        
dist: {               
    files: {                    
        'styles/style.css': 'styles/style.scss'   
    }
},
dev: {                              // another target
    options: {                      // dictionary of render options
        sourceMap: false
    },
    files: {
        'styles/style.css': 'styles/style.scss'
    }
}
},

cssmin: {
minify: {
    expand: true,
    cwd: 'styles/',
    src: ['*.css', '!*.min.css'],
    dest: 'styles/',
    ext: '.min.css'
}
},
uglify: {
build: {
    src: 'js/global.js',
    dest: 'js/build/production.min.js'
}
},

imagemin:{
  dynamic:{
  files: [{
     expand:true,
     cwd: 'img/',
     src: ['**/*.{png,jpg}'],
     dest: 'images/build'
}]
}
}
});

 // Load the plugin that provides the task that are being.
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-imagemin');

// Default task(s).
grunt.registerTask('default', ['watch', 'sass', 'cssmin', 'uglify', 'imagemin']);

};

例如:当我在css上做出改变时;它每次运行sass,cssmin,uglify和imagemin而不是仅改变css ..

是否可以将grunt-watch手表设置为仅更改文件?

0 个答案:

没有答案