Skip to content

Commit

Permalink
added grunt task to minify all js files for the admin and the frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiosanches committed Feb 2, 2014
1 parent ddf6f7b commit e4d6c0b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
43 changes: 43 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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', [
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit e4d6c0b

Please sign in to comment.