0

When running the final build step in GULP, I am trying to use uglify with a wildcard in the gulp.src, but seeing an error.

This works:

gulp.task('build', ['lint','karma','clean'], function () {
return gulp.src('./src/js/file.js')
    .pipe(gulp.dest('./dist'))
    .pipe(uglify())
    .pipe(size())
    .pipe(gulp.dest('./dist'));
});

But this doesn't:

gulp.task('build', ['lint','karma','clean'], function () {
return gulp.src('./src/js/*.js')
    .pipe(gulp.dest('./dist'))
    .pipe(uglify())
    .pipe(size())
    .pipe(gulp.dest('./dist'));
});

The only difference being that I select a specific file in the working gulp.src, but use a wildcard in the non-working version. I have narrowed this down to uglify() because if I comment it out, I don't get the error, and everything completes without issue.

Any help would be greatly appreciated

8
  • Why do you call gulp.dest twice in the same pipeline? Does removing the first one solve the problem? Commented Sep 28, 2015 at 23:27
  • There is no change. From what I understood (still new to GULP), this was to set where the data was to be placed while the rest of the operations were performed, then the second one was where the final output was located. It may not be necessary, but I have seen the example in several gulp files. Commented Sep 28, 2015 at 23:36
  • 1
    Sometimes it's required to put the files in once place, transform them, and then store them in another. Here though you're just storing them in the same place so no need for the first call to gulp.dest. What's the error you're getting? Commented Sep 28, 2015 at 23:39
  • And that makes sense. The error is: events.js:85 throw er; // Unhandled 'error' event with all of the corresponding reference to differing lines in: events.js:85 throw er; // Unhandled 'error' event ^ /Users/andrewr/Development/viper-probe-droid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js Commented Sep 28, 2015 at 23:44
  • Looks like there's an unexpected character in one of your JS files. Do you have minified files or source maps in the src/js folder also? Commented Sep 28, 2015 at 23:47

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.