Search code examples
gulpgulp-concat

Gulp concat jQuery throws error


I'm pretty new to gulp. I'm trying to merge few JS files together and when I add jQuery (or jQuery UI) compiler throws error:

events.js:160
  throw er; // Unhandled 'error' event
  ^
Error: [path]\public\components\jquery\dist\jquery.js:16:2: missing '}'

My jQuery is fresh copy via bower (version 3.2.1) as is jQuery UI (1.12.1).

My gulp task is following:

gulp.task('js', function() {
    gulp.src(
        [
            config.bowerDir + '/jquery/dist/jquery.js',
            config.bowerDir + '/jquery-ui/jquery-ui.js',
            './public/js/custom.js'
        ]
    )
        .pipe(concat('script.js'))
        .pipe(gulp.dest('./public/js/'));
} );

Any help would be very much appreciated.


Solution

  • Sorry all, problem was in my own stupidity. My concat function was actually gulp-concat-css and not gulp-concat. Took me three days to spot the error.

    (...)
    var concat = require('gulp-concat');
    (...)
    
    gulp.task('js', function() {
        return gulp.src([
                config.bowerDir + '/jquery/dist/jquery.js',
                config.bowerDir + '/jquery-ui/jquery-ui.js',
                './public/js/custom.js'
            ])
            .pipe(concat('scripts.js'))
            .pipe(gulp.dest('./public/js/'));