Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/duan602728596/gulp-terser
gulp plugin, compressed es6+ code.
https://github.com/duan602728596/gulp-terser
gulp gulpplugin
Last synced: 2 months ago
JSON representation
gulp plugin, compressed es6+ code.
- Host: GitHub
- URL: https://github.com/duan602728596/gulp-terser
- Owner: duan602728596
- License: mit
- Created: 2017-09-22T10:24:06.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-07-30T05:37:14.000Z (5 months ago)
- Last Synced: 2024-09-30T23:17:00.274Z (3 months ago)
- Topics: gulp, gulpplugin
- Language: JavaScript
- Size: 72.3 KB
- Stars: 64
- Watchers: 2
- Forks: 9
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gulp-terser
Gulp plugin, compressed es6+ code.
## Install
```
$ npm install gulp-terser --save-dev
```
or
```
$ yarn add gulp-terser --dev
```## How to use
```javascript
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](https://github.com/terser-js/terser#minify-options).
```javascript
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
```javascript
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:
```javascript
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;
```