Last active
December 23, 2015 06:19
-
-
Save sunpietro/6593428 to your computer and use it in GitHub Desktop.
Grunt directives:
* removing minified files,
* uglifying them and keeping original filename (with dots), adding only min.js extension at the end;
* concatenating minified JS files,
* minifying CSS files,
* copying minified files to production directory Gruntfile.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(grunt) { | |
'use strict' | |
grunt.initConfig({ | |
clean : [ | |
'js/GoalApp/js/modules/**/*.min.js', | |
'css/GoalApp/css/*.min.css' | |
], | |
uglify : { | |
build : { | |
src : ['**/*.js', '!*.min.js'], | |
cwd : 'js/GoalApp/js/', | |
dest : 'js/GoalApp/js/', | |
expand : true, | |
rename : function (dest, src) { | |
// src modules/news/news.main.js | |
var folder = src.substring(0, src.lastIndexOf('/')); | |
var filename = src.substring(src.lastIndexOf('/'), src.length); | |
filename = filename.substring(0, filename.lastIndexOf('.')); | |
// return js/GoalApp/js/modules/news/news.main.min.js | |
return dest + folder + filename + '.min.js'; | |
} | |
} | |
}, | |
concat: { | |
options: { | |
separator: ';' | |
}, | |
dist: { | |
src: ['js/GoalApp/js/modules/**/*.min.js'], | |
dest: 'js/GoalApp/js/modules/modules.min.js' | |
} | |
}, | |
cssmin : { | |
minify : { | |
expand: true, | |
cwd : 'css/GoalApp/css/', | |
src : ['*.css', '!*.min.css'], | |
dest : 'css/GoalApp/css/', | |
ext : '.min.css' | |
} | |
}, | |
copy : { | |
js : { | |
files : [{ | |
expand : true, | |
cwd : 'js/', | |
src : ['**/*.min.js'], | |
dest : 'production/js/' | |
}] | |
} | |
} | |
}); | |
grunt.loadNpmTasks('grunt-contrib-clean'); | |
grunt.loadNpmTasks('grunt-contrib-uglify'); | |
grunt.loadNpmTasks('grunt-contrib-cssmin'); | |
grunt.loadNpmTasks('grunt-contrib-concat'); | |
grunt.loadNpmTasks('grunt-contrib-copy'); | |
grunt.registerTask('default', ['clean', 'uglify', 'cssmin', 'concat', 'copy']); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment