Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I have multiple jsHint task configured in a single Grunt file?

Tags:

gruntjs

I have a grunt file configured for 2 different modules. In a single task i can give multiple sources and it all works fine. Now my requirement is to give different options for both the modules say - I want different JsHint rules for both modules and I want both the projects to have separate minified files and a common minified file.

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']
      }
  }

}

I saw some of the stack overflow question, but i could only find Grunt-hub as an option where i need to create 2 separate files and then a grunt hub file. I dont want to do that, please guide me how to proceed?

like image 282
VKS Avatar asked Dec 27 '22 04:12

VKS


1 Answers

Use targets: http://gruntjs.com/configuring-tasks#task-configuration-and-targets

grunt.initConfig({
  jshint: {
    one: {
      src: ['files/*'],
      options: { /* ... */ }
    },
    two: {
      src: ['files2/*'],
      options: { /* ... */ }
    }
  }
});
like image 139
Kyle Robinson Young Avatar answered Apr 30 '23 01:04

Kyle Robinson Young