diff --git a/Gruntfile.js b/Gruntfile.js index b800723d3c670..8e17ec2edad76 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -43,6 +43,47 @@ module.exports = function( grunt ){ } }, + // Minify .js files. + uglify: { + options: { + preserveComments: 'some' + }, + admin: { + files: [{ + expand: true, + cwd: '<%= dirs.js %>/admin/', + src: [ + '*.js', + '!*.min.js', + '!jquery.flot*' // !jquery.flot* prevents to join all jquery.flot files in jquery.min.js + ], + dest: '<%= dirs.js %>/admin/', + ext: '.min.js' + }] + }, + adminflot: { // minify correctly the jquery.flot lib + files: { + '<%= dirs.js %>/admin/jquery.flot.min.js': ['<%= dirs.js %>/admin/jquery.flot.js'], + '<%= dirs.js %>/admin/jquery.flot.pie.min.js': ['<%= dirs.js %>/admin/jquery.flot.pie.js'], + '<%= dirs.js %>/admin/jquery.flot.resize.min.js': ['<%= dirs.js %>/admin/jquery.flot.resize.js'], + '<%= dirs.js %>/admin/jquery.flot.stack.min.js': ['<%= dirs.js %>/admin/jquery.flot.stack.js'], + '<%= dirs.js %>/admin/jquery.flot.time.min.js': ['<%= dirs.js %>/admin/jquery.flot.time.js'], + } + }, + frontend: { + files: [{ + expand: true, + cwd: '<%= dirs.js %>/frontend/', + src: [ + '*.js', + '!*.min.js' + ], + dest: '<%= dirs.js %>/frontend/', + ext: '.min.js' + }] + }, + }, + shell: { txpull: { options: { @@ -70,11 +111,13 @@ module.exports = function( grunt ){ grunt.loadNpmTasks( 'grunt-shell' ); grunt.loadNpmTasks( 'grunt-contrib-less' ); grunt.loadNpmTasks( 'grunt-contrib-cssmin' ); + grunt.loadNpmTasks( 'grunt-contrib-uglify' ); // Register tasks grunt.registerTask( 'default', [ 'less', 'cssmin', + 'uglify' ]); grunt.registerTask( 'dev', [ diff --git a/package.json b/package.json index e59d7d984c1a5..f441f83ef85d1 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "main": "Gruntfile.js", "devDependencies": { "grunt": "~0.4.2", - "grunt-contrib-uglify": "~0.2.2", + "grunt-contrib-uglify": "~0.3.2", "grunt-contrib-less": "~0.9.0", "grunt-contrib-cssmin": "~0.7.0", "grunt-shell": "~0.6.4"