Alternate grunt.js tasks for dev/prod environments

I am trying to set up my grunt.js file so it only runs the min task when running on my production server - when running on my local dev server I don't want to min my code with every change as it is unnecessary.

Any ideas on how grunt.js can differentiate between dev/prod environments?



Register a production task:

// on the dev server, only concat
grunt.registerTask('default', ['concat']);

// on production, concat and minify
grunt.registerTask('prod', ['concat', 'min']);

On your dev server run grunt and on your production run grunt prod.

You can setup finer grain targets per task as well:

  min: {
    dev: {
      // dev server minify config
    prod: {
      // production server minify config
grunt.registerTask('default', ['min:dev']);
grunt.registerTask('prod', ['min:prod']);


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.