• Stars
    star
    1,229
  • Rank 38,186 (Top 0.8 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 11 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Minify files with UglifyJS

gulp-uglify

Minify JavaScript with UglifyJS3.

Installation

Install package with NPM and add it to your development dependencies:

npm install --save-dev gulp-uglify

Usage

var gulp = require('gulp');
var uglify = require('gulp-uglify');
var pipeline = require('readable-stream').pipeline;

gulp.task('compress', function () {
  return pipeline(
        gulp.src('lib/*.js'),
        uglify(),
        gulp.dest('dist')
  );
});

To help properly handle error conditions with Node streams, this project recommends the use of pipeline, from readable-stream.

Options

Most of the minify options from the UglifyJS API are supported. There are a few exceptions:

  1. The sourceMap option must not be set, as it will be automatically configured based on your Gulp configuration. See the documentation for Gulp sourcemaps.

Errors

gulp-uglify emits an 'error' event if it is unable to minify a specific file. The GulpUglifyError constructor is exported by this plugin for instanceof checks. It contains the following properties:

  • fileName: The full file path for the file being minified.
  • cause: The original UglifyJS error, if available.

Most UglifyJS error messages have the following properties:

  • message (or msg)
  • filename
  • line

To see useful error messages, see Why Use Pipeline?.

Using a Different UglifyJS

By default, gulp-uglify uses the version of UglifyJS installed as a dependency. It's possible to configure the use of a different version using the "composer" entry point.

var uglifyjs = require('uglify-js'); // can be a git checkout
                                     // or another module (such as `uglify-es` for ES6 support)
var composer = require('gulp-uglify/composer');
var pump = require('pump');

var minify = composer(uglifyjs, console);

gulp.task('compress', function (cb) {
  // the same options as described above
  var options = {};

  pump([
      gulp.src('lib/*.js'),
      minify(options),
      gulp.dest('dist')
    ],
    cb
  );
});

More Repositories

1

StickersStandard

The Stickers Standard
425
star
2

docker-npmjs

Docker image for a private npmjs repository
Shell
154
star
3

ziggetty

A Static Server in Zig
Zig
25
star
4

promisescript

Promise-based JavaScript, JSON, and CSS loader
JavaScript
19
star
5

zClip

JavaScript
17
star
6

gulp-license

Add licenses to gulp streams.
JavaScript
15
star
7

HPSS-Disassembly

Work in Progress disassembly of Harry Potter and the Sorcerer's Stone (GBC)
Assembly
13
star
8

mixere

A modern fork of mixere, a Windows audio mixer for live productions.
C++
10
star
9

promise-series

Resolve promises in a series
JavaScript
10
star
10

flipper-barcode

A barcode generator for the Flipper Zero
C
10
star
11

openrct2-prometheus-exporter

An OpenRCT2 plugin that implements a Prometheus exporter.
Nix
10
star
12

inferno-hyperscript

Hyperscript syntax for Inferno termplates.
JavaScript
9
star
13

MediaKeyKit

Bringing sanity to your Mac's media keys
Objective-C
8
star
14

enotes-for-github

E-Notes for GitHub
JavaScript
7
star
15

gulp-closure

Minify files with Closure Compiler
JavaScript
6
star
16

docker-couchdb

Shell
6
star
17

terinjokes

Terin's Jokes
JavaScript
5
star
18

bakelite

injects resin into a mold to produce groovy Go programs
Go
5
star
19

rwhois

Ruby
5
star
20

BlackScreen

Setting the wallpaper of all your screens to black (or another custom image), so you don't have to.
4
star
21

terinstock.com

HTML
4
star
22

mmxmpcr

command line program for playing the XM Radio PCR satellite radio receiver
C++
3
star
23

BMDSwitcherMock

A Mock COM for testing against the BMDSwitcherAPI
C++
3
star
24

assume-sinon

JavaScript
3
star
25

stolport

Tracking location and history of physical items with short IDs.
Go
3
star
26

contenteditable

Fixing contenteditable
JavaScript
3
star
27

human-intermediate-formats

List of human-editable intermediate file formats
3
star
28

nofiles

The best way to write secure computing. Write nothing.
3
star
29

stgit

Stacked Git
Python
3
star
30

license-wizard-2000

Clojure
3
star
31

eslispify

browserify transform for eslisp
JavaScript
2
star
32

dos.nix

A Nixpkgs overlay collection of DOS tools
Nix
2
star
33

AFOAuth1

OAuth 1.0 client for AFNetworking
Objective-C
2
star
34

terinjokes.github.com

CSS
2
star
35

baywheels-history

Tracking Bay Wheels system data
Shell
2
star
36

k9p

Go
2
star
37

badge-ify

2
star
38

Blocksbook

Fork of miekg's blocksbook style
2
star
39

flarectl

CLI interaction with CloudFlare
JavaScript
2
star
40

karma-tape-reporter

Karma plugin that reports TAP formated results
JavaScript
2
star
41

userstyles

A collection of personal userstyles
CSS
2
star
42

stoneknife

Go port of https://github.com/kragen/stoneknifeforth
Go
2
star
43

mailpail

Export Bitbucket Server pull requests to Maildir
Go
2
star
44

home.nix

Nix
1
star
45

extra-ports

Personal collection of additional (or upgraded) MacPort ports
Tcl
1
star
46

tforth

fasm-based forth for x86_64 Linux systems
Assembly
1
star
47

break3812

Breakout board for the Yamaha YM3812-F
Nix
1
star
48

docker-npmjs-delegate

Shell
1
star
49

autoresponder

Python
1
star
50

dotfiles

My dotfiles (more or less)
Shell
1
star
51

docker-npmjs-skim

Shell
1
star