Reputation: 2481
how to specify a separator in this scenario:
I'm concatenating my files with grunt-concat this way:
concat: {
options: {
banner: '<%= banner %>',
separator: ""
},
dist: {
files:{
'<%= distdir %>/public/scripts/ieditor.js': [
'public/scripts/ieditor/vars.js',
'public/scripts/ieditor/controllers/*.js',
'public/scripts/ieditor/directives/*.js',
'public/scripts/ieditor/app.js',
'public/scripts/ieditor/services/*.js',
'public/scripts/ieditor/filters/*.js'
],
'<%= distdir %>/public/scripts/dashboard.js': [
'public/scripts/dashboard/vars.js',
'public/scripts/dashboard/controllers/*.js',
'public/scripts/dashboard/directives/*.js',
'public/scripts/dashboard/app.js',
'public/scripts/dashboard/services/*.js',
'public/scripts/dashboard/filters/*.js'
]
}
}
}
what I want is to get a final result mapped to the original files like in compass when concatenating CSS files.
Example:
//####public/scripts/ieditor/vars.js###############
content of public/scripts/ieditor/vars.js
//####public/scripts/ieditor/controllers/a.js######
content of public/scripts/ieditor/controllers/a.js
//####public/scripts/ieditor/controllers/b.js######
content of public/scripts/ieditor/controllers/b.js
.....
So what's the name referring to the current file being concatenated so i can do something like this in the options area:
options: {
banner: '<%= banner %>',
separator: "<%= current_file_name %>"
},
Thanks in advance.
Upvotes: 12
Views: 3933
Reputation: 4718
The process
option, specified as a function, is your friend:
concat: {
options: {
process: function(src, filepath) {
return '//####' + filepath + '\n' + src;
}
}
},
...
Upvotes: 20