Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add break-line between files Grunt - concat

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.

like image 462
Vadorequest Avatar asked Nov 27 '13 21:11

Vadorequest


2 Answers

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;
like image 87
Scott Mermelstein Avatar answered Nov 14 '22 07:11

Scott Mermelstein


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.

like image 23
Mik378 Avatar answered Nov 14 '22 05:11

Mik378