我可以在单个Grunt文件中配置多个jsHint任务吗?

时间:2013-05-13 16:25:39

标签: gruntjs

我为2个不同的模块配置了一个grunt文件。在一个任务中,我可以提供多个来源,一切正常。 现在我的要求是为两个模块提供不同的选项 - 我希望两个模块都有不同的JsHint规则,我希望这两个项目都有单独的缩小文件和一个通用的缩小文件。

Gruntfile.js - >

jshint:{

  ac:{
      options: {

          laxcomma: true, // maybe we should turn this on? Why do we have these 
          curly: true,
          eqeqeq: true,
          immed: true,
          latedef: true,
          onevar: true
      },
      source: {
          src: ['module1/*.js']
      }
  },
  lib:{
      options: {
          laxcomma: true, // maybe we should turn this on? Why do we have these 
          curly: true,
          eqeqeq: true,
          immed: true,
          latedef: true
      },
      source: {
          src: ['module2/*.js']
      }
  }

}

我看到了一些堆栈溢出问题,但我只能找到Grunt-hub作为一个选项,我需要创建2个单独的文件,然后是一个grunt hub文件。我不想这样做,请指导我如何继续?

1 个答案:

答案 0 :(得分:10)

使用目标:http://gruntjs.com/configuring-tasks#task-configuration-and-targets

grunt.initConfig({
  jshint: {
    one: {
      src: ['files/*'],
      options: { /* ... */ }
    },
    two: {
      src: ['files2/*'],
      options: { /* ... */ }
    }
  }
});
相关问题