Questions tagged [gulp-uglify]

gulp-uglify is a gulp plugin for files minification using UglifyJS.

gulp-uglify integrates files minification using UglifyJS into gulp workflow. It's as easy to use as:

var uglify = require('gulp-uglify');

gulp.task('make-it-ugly', function() {
  return gulp.src('app/components/*.js')
    .pipe(uglify())
    .pipe(gulp.dest('build'));
});

gulp-uglify npm package: https://www.npmjs.com/package/gulp-uglify.

251 questions
80
votes
8 answers

Uglify SyntaxError: Unexpected token: punc ())

I am trying to use gulp in order to minify a folder containing JS files. However, one of the files has the above error, preventing it from being minified. I managed to catch and print the error, which I've partially printed here: JS_Parse_Error { …
Alexander
  • 999
  • 1
  • 9
  • 18
64
votes
1 answer

Gulp uglify output min.js

The js file being compressed is output with the same filename. gulp.task('compressjs', function () { gulp.src('app/**/*.js') .pipe(uglify()) .pipe(gulp.dest('dist')); }); How can I have it output the file with min.js at the back?
user1995781
  • 19,085
  • 45
  • 135
  • 236
63
votes
8 answers

GulpUglifyError:Unable to minify JavaScript

I am trying to minify my script files for which i am using gulp task runner And I am trying gulp-uglify plugin Code: gulp.task('concat', function() { return gulp.src('app/**/*.js') // .pipe(concat('script.js')) .pipe(uglify()) …
swathi anupuram
  • 795
  • 1
  • 7
  • 14
63
votes
7 answers

Gulp-uglify : throw er; // Unhandled 'error' event

i'm pretty new to gulp , and I follow tutorials in http://leveluptuts.com/tutorials/learning-gulp , I get this error: events.js:141 throw er; // Unhandled 'error' event ^ Error at new JS_Parse_Error…
khue bui
  • 1,366
  • 3
  • 22
  • 30
53
votes
9 answers

How to minify ES6 functions with gulp-uglify?

When I run gulp I get the following error: [12:54:14] { [GulpUglifyError: unable to minify JavaScript] cause: { [SyntaxError: Unexpected token: operator (>)] message: 'Unexpected token: operator (>)', filename: 'bundle.js', line: 3284, col: 46, …
Don
  • 3,876
  • 10
  • 47
  • 76
22
votes
6 answers

Gulp uglify unable to handle arrow functions

I'm trying to compress my project using gulp-uglify, however gulp seems to throw the error Unexpected token: punc () whenever it encounters an arrow function in the code. Is there anything I can do to fix this? Thank you. gulp-crash-test.js //…
Paradoxis
  • 4,471
  • 7
  • 32
  • 66
22
votes
4 answers

Uglify throws Parse error

When i use gulp-uglify with browserify i get a error events.js:72 throw er; // Unhandled 'error' event ^ Error at new JS_Parse_Error…
rkmax
  • 17,633
  • 23
  • 91
  • 176
14
votes
4 answers

Mangle all variables except one with gulp-uglify

Is there a way to mangle all variables except a specific one with gulp-uglify?
deleted
  • 772
  • 1
  • 6
  • 19
14
votes
3 answers

Why isn't gulp-uglify mangling my variables names?

I have the following task: var uglify = require('gulp-uglify'); gulp.task('scripts', function () { gulp.src('./src/scripts/*.js') .pipe(concat('main.js')) .pipe(uglify()) .pipe(gulp.dest('./dist')); }); And the following 2 javascript…
user818700
13
votes
2 answers

gulp-uglify events.js unhandled 'error' event

I'm getting this error. Running gulp yesterday worked perfectly fine, but this morning (changed NO code) and I'm getting this error. $ gulp [08:54:10] Using gulpfile C:\Source\Source2\bunny-meadows\gulpfile.js [08:54:10] Starting…
HaleyBuggs
  • 915
  • 3
  • 13
  • 29
11
votes
3 answers

Uglification failed. Unexpected character '`'

gulp-uglify is unable to uglify this piece of code: var alertString = ` ${title}
sailens
  • 1,594
  • 1
  • 17
  • 34
10
votes
1 answer

Gulp-sourcemaps not creating a sourcemap file?

I'm trying to get Gulp sourcemaps to write files, but I can't see these files anywhere. If any new files were created in the working tree, I would see them in git status, but nothing no new files to be found. Below is my gulpfile.js var gulp =…
Martyn
  • 6,031
  • 12
  • 55
  • 121
8
votes
1 answer

how to uglify javascript classes?

I'm writing basic javascript using the classes syntax and trying to uglify it with gulp, but getting this error: events.js:72 throw er; // Unhandled 'error' event I simply used the example code from mozilla's website: class Polygon { …
Jeff Puckett
  • 37,464
  • 17
  • 118
  • 167
7
votes
1 answer

Keep license comments when using UglifyJS2 with gulp plugin

In this project i am using gulp-uglify version 3.0.1 and i want to preserve comments containing license texts in the output. On the projects page it is stated that Most of the minify options from the UglifyJS API are supported. and this answer…
x29a
  • 1,761
  • 1
  • 24
  • 43
7
votes
2 answers

How to Minify ES6 Using Gulp

I am relatively new to writing a gulpfile.js manually. I have a Backbone and Marionette based project where the gulp file so far looked like the following: var gulp = require('gulp'); var $ = require('gulp-load-plugins')(); var browserify =…
Nikhil Khullar
  • 703
  • 6
  • 21
1
2 3
16 17