使用一个任务的输出作为另一个任务的输入

时间:2013-04-02 06:08:25

标签: gruntjs

我有一个html文件,其中包含对js文件的引用。我想解析它提取引用的js文件列表并提供contrib-concat或任何其他任务。 有没有方便的方法将一个grunt任务的输出用作另一个的输入?

1 个答案:

答案 0 :(得分:4)

使用grunt.config。这是一个例子:

grunt.initConfig({
  concat: {
    js: {
      src: ['default/concat/files/*'],
      dest: ['dist/javascript.js'],
    },
  },
});
grunt.registerTask('extractjs', function() {
  /* Do the js extraction */
  // Overwrite the concat.js.src with your extracted files.
  grunt.config(['concat', 'js', 'src'], extractedFiles);
});

所以现在当你运行grunt extractjs concat时,它将提取js然后连接提取的js文件。看看这个任务:https://github.com/cgross/grunt-dom-munger因为他正在制定类似的目标。这是一个含有更多示例的咕噜声问题:https://github.com/gruntjs/grunt/issues/747

相关问题