gruntjs/grunt-contrib-concat

Concatenating files that end in comments adds the first line of new files as comments too

hdwebpros opened this issue · 0 comments

npm install bootstrap
Then setup your Gruntfile with these options:

concat: {
        options: { 
          separator: ';'
        },
        modal: {
          src: ["node_modules/bootstrap/js/dist/util.js","node_modules/bootstrap/js/dist/modal.js"],
          dest: "js/modal.js"
        }
     },

Now open your modal.js file.

Look at line 139. It reads
//# sourceMappingURL=util.js.map;function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

And the function _extends() gets put in with that comment.

If you edit the util.js file and add an extra line after it, the file concatenates properly, saving that function.

I'm not sure if the true fix is to force a new line after every file that ends in a comment, or fix concatenate to detect if this is true and add that new line afterwards.