I would like to know if there is a way to add a line between each file when we concat the files using Grunt concat.
Because I get errors due to some inline comments in end of file which, when they are merged comments also the first line of the next file.
A little tricky actually, I'm removing these comments manually but if I could avoid definitively this issue, could be better.
Just add a line for each file concat could be great. I'll remove comments and spaces with Grunt - uglify next.
https://github.com/gruntjs/grunt-contrib-concat mentions the separator
option and even gives a usage example for using a custom separator.
Here's their example:
grunt.initConfig({
concat: {
options: {
separator: ';',
},
dist: {
src: ['src/intro.js', 'src/project.js', 'src/outro.js'],
dest: 'dist/built.js',
},
},
});
If that doesn't do it for you, you can probably change the seapartor
line to:
separator: grunt.util.linefeed + ';' + grunt.util.linefeed;
Inspecting the grunt-contrib-concat documentation, you could try the separator
option.
Concatenated files will be joined on this string. If you're post-processing concatenated JavaScript files with a minifier, you may need to use a semicolon ';' as the separator.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With