I'm trying to set up a customized Gruntfile.js to use as a boilerplate on future projects (mostly web performance optimization tasks).
The task most relevant to this question is concatenation. Here's the configuration of that task from a recent project:
concat: {
css: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n',
},
src: [
'wp-content/plugins/orangebox/css/orangebox.css',
'wp-content/themes/caps/style.css',
'styles.css',
'contact.css',
'pro_dropdown_2/pro_dropdown_2.css',
'css/slider.css'
],
dest: 'combined.<%= grunt.template.today("ddmmyyyy") %>.css'
},
js: {
options: {
banner: '/*! <%= pkg.name %>-Version-<%= pkg.version %>-Compiled-<%= grunt.template.today("dd-mm-yyyy") %> */\n',
},
src: [
'cformnkp.js',
'AC_RunActiveContent.js',
'js/moo_12.js',
'js/sl_slider.js',
'js/swfobject.js',
'scripts/*.js',
'pro_dropdown_2/*js'
],
dest: 'concat.<%= grunt.template.today("ddmmyyyy") %>.js',
separator: ";"
}
},
So that any other developers after me know what I did, I'd like to include a comment before each section of concatenated code (i.e. a 'banner') that would say what the original file name was before I concatenated them all.
It'd also be pretty cool if the new file was named obviously. For instance, if the concatenated JS file was cformnkp-AC_RunActiveContent-moo_12-sl_slider-swfobject.js
(this is neglecting the dynamically added files, as well as the last specifically enumerated file but you get the idea).
I thought <%= pkg.name %>
might accomplish this but it only inserts the name of my package as listed in package.json
.
I can't fully make sense of the LoDash template documentation, and nothing on here seems to indicate how to do this even though is seems pretty straight-forward. A little help?