`

grunt配置-clean任务

 
阅读更多
grunt-contrib-clean插件-tasks目录下clean.js文件中配置了一个clean任务:
grunt.registerMultiTask('clean', 'Clean files and folders.', function() {
    // Merge task-specific and/or target-specific options with these defaults.
    var options = this.options({
      force: grunt.option('force') === true,
      'no-write': grunt.option('no-write') === true,
    });

    grunt.verbose.writeflags(options, 'Options');

    // Clean specified files / dirs.
    this.filesSrc.forEach(function(filepath) {
      clean(filepath, options);
    });
  });


所以在Gruntfile.js中配置任务的时候很简单:
        grunt.initConfig({
           clean : {
                dist : ['/a','/b','/c'],
                server : 'a'
           }
           
        }),

这样执行 grunt clean:dist 命令时就可以成功删除 a.b.c 目录下的文件。

https://www.npmjs.com/package/grunt-contrib-clean
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics