grunt failing due to parse error from commented out code

804 views Asked by At

When I concat a bunch of js, including jquery, I get an error when I grunt complaining about 'unexpected token (]) at line 1019844...' and I look at that line, it has code that is commented out that should not be commented out

//# sourceMappingURL=jquery.min.map;define([
    "./core",
    "./var/rnotwhite",
    "./ajax/var/nonce",
    "./ajax/var/rquery",
    "./core/init",
    "./ajax/parseJSON",
    "./ajax/parseXML",
    "./deferred"
], function( jQuery, rnotwhite, nonce, rquery ) {

At the first row is a comment that should not be a comment, how would I deal with this for grunt without manual intervention?

edit: snippet of my gruntjs

concat: {
      // Specify some options, usually specific to each plugin.
       options:{
        separator: ';'
      },
      js: {
        src: ['<%= srcJavascript %>/**/*.js'],
        dest: '<%= concatJavascript %>/gtg-js.js'
      },
      css:{
        src: ['<%= srcCss %>/**/*.css'],
        dest: '<%= concatCss %>/gtg-css.css'   
      }    
    },  
    uglify: {
        build: {
            files :{
                '<%= targetJavascript %>/gtg-js-uglify.js':['<%= concatJavascript %>/gtg-js.js']
            }               
        },
        options: {
            banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n',
            compress: true,
            mangle: true
        }
    },
    cssmin: {
        css: {
            src:'<%= concatCss %>/gtg-css.css', 
            dest: '<%= targetCss %>/gtg-css-min'
        }
     }

.....
  // We've set up each task's configuration.
  // Now actually load the tasks.
  // This will do a lookup similar to node's require() function.
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-cssmin');


  // Register our own custom task alias.
  grunt.registerTask('default', ['concat', 'uglify', 'cssmin']);
1

There are 1 answers

0
Kristoffer Jälén On

After concatenating, replace this line:

//# sourceMappingURL=jquery.min.map;define([

with:

//# sourceMappingURL=jquery.min.map;
define([

There are two occurrences.