gulp-terser
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/gulp-terser package

2.1.0 • Public • Published

gulp-terser

Gulp plugin, compressed es6+ code.

Install

$ npm install gulp-terser --save-dev

or

$ yarn add gulp-terser --dev

How to use

const gulp = require('gulp');
const terser = require('gulp-terser');

function es(){
  return gulp.src('./src/index.js')
    .pipe(terser())
    .pipe(gulp.dest('./build'));
}

exports.default = es;

Options

Terser configuration can be viewed https://github.com/terser-js/terser#minify-options.

const gulp = require('gulp');
const terser = require('gulp-terser');

function es(){
  return gulp.src('./src/index.js')
    .pipe(terser({
      keep_fnames: true,
      mangle: false
    }))
    .pipe(gulp.dest('./build'));
}

exports.default = es;

Use a 3rd-party version of minifier

const gulp = require('gulp');
const terser = require('terser');
const gulpTerser = require('gulp-terser');

function es(){
  return gulp.src('./src/index.js')
    .pipe(gulpTerser({}, terser.minify))
    .pipe(gulp.dest('./build'));
}

exports.default = es;

Use sourcemaps

You can use sourcemaps like this:

const gulp = require('gulp');
const sourcemaps = require('gulp-sourcemaps');
const terser = require('gulp-terser');

function es(){
  return gulp.src('./src/**/*.js')
    .pipe(sourcemaps.init())
    .pipe(terser())
    .pipe(sourcemaps.write('./'))
    .pipe(gulp.dest('./build'));
}

exports.default = es;

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
2.1.037,530latest

Version History

VersionDownloads (Last 7 Days)Published
2.1.037,530
2.0.12,046
2.0.0142
1.4.17,499
1.4.02,485
1.3.238
1.3.10
1.3.022
1.2.126
1.2.01,486
1.1.7222
1.1.645
1.1.59
1.1.40
1.1.30
1.1.20
1.1.10
1.0.11
1.0.01

Package Sidebar

Install

npm i gulp-terser

Weekly Downloads

51,552

Version

2.1.0

License

MIT

Unpacked Size

7.2 kB

Total Files

5

Last publish

Collaborators

  • duan602728596