Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including gulp-uglify-es with all npm packages installed. Try it out:

var gulpUglifyEs = require("gulp-uglify-es")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

gulp-uglify-es v2.0.0

gulp stream to uglify with 'terser' (es6 supported).

gulp-uglify-es

gulp stream to uglify with 'terser' (es6 supported).

terser is the new 'uglify-es'. uglify-es is no longer maintained.

Install

npm install --save-dev gulp-uglify-es

Usage

gulpfile.js

let gulp = require("gulp");
let rename = require("gulp-rename");
let uglify = require('gulp-uglify-es').default;

gulp.task("uglify", function () {
    return gulp.src("lib/bundle.js")
        .pipe(rename("bundle.min.js"))
        .pipe(uglify(/* options */))
        .pipe(gulp.dest("lib/"));
});

For documentation about the options-object, See the Uglify API Reference.

Source maps

To generate source maps, use gulp-sourcemaps.
Example:

let gulp = require("gulp");
let rename = require("gulp-rename");
var sourcemaps = require('gulp-sourcemaps');
let uglify = require('gulp-uglify-es').default;

gulp.task("uglify", function () {
    return gulp.src("lib/bundle.js")
        .pipe(rename("bundle.min.js"))
        .pipe(sourcemaps.init())
        .pipe(uglify())
        .pipe(sourcemaps.write()) // Inline source maps.
        // For external source map file:
        //.pipe(sourcemaps.write("./maps")) // In this case: lib/maps/bundle.min.js.map
        .pipe(gulp.dest("lib/"));
});
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free