Skip to content

Instantly share code, notes, and snippets.

@MoOx
Last active December 14, 2015 21:38
Show Gist options
  • Save MoOx/5152368 to your computer and use it in GitHub Desktop.
Save MoOx/5152368 to your computer and use it in GitHub Desktop.
Grunt.js: Concat or Uglify depending on the ENV

Usage

Dev

grunt scripts

Dist

grunt scripts -env=dist
/*global module:false require:true*/
module.exports = function(grunt) {
"use strict";
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
// set option
grunt.option('env', typeof grunt.option('env') !== 'undefined' ? grunt.option('env') : 'dev');
var scripts = grunt.file.readJSON('configs/scripts.json');
// Project configuration.
grunt.initConfig({
concat: {
scripts_board: { files: scripts.board },
},
uglify: {
scripts_board: { files: scripts.board },
}
});
var task_scripts = (grunt.option('env') === 'dist' ? 'uglify' : 'concat');
grunt.registerTask('scripts', [ task_scripts + ':scripts_board']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment