Add dividing line between grunt files - concat

I would like to know if there is a way to add a line between each file when we merge files using Grunt concat.

Because I get errors due to some inline comments at the end of the file, which, when combined, also comment on the first line of the next file.

It’s actually a bit complicated, I delete these comments manually, but if I could avoid this problem it might be better.

Just add a line for each concat file. I will remove comments and spaces with Grunt - uglify next.

+7
javascript gruntjs
source share
2 answers

https://github.com/gruntjs/grunt-contrib-concat mentions the separator option and even provides a usage example for using a custom separator.

Here is an example of them:

 grunt.initConfig({ concat: { options: { separator: ';', }, dist: { src: ['src/intro.js', 'src/project.js', 'src/outro.js'], dest: 'dist/built.js', }, }, }); 

If this is not for you, you can change the seapartor line to:

 separator: grunt.util.linefeed + ';' + grunt.util.linefeed; 
+9
source share

By checking out the grunt-contrib-concat document , you can try the separator option.

Concatenated files will be merged into this line. If you are post-processed concatenated JavaScript files using the minifier, you may need to use the semicolon ';' as a separator.

+1
source share

All Articles