Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Minify (not transpile) ES2015 code with Gulp

How to minify ES2015 code without transpiling it to ES5? The popular gulp-minify and gulp-uglify modules do not work with simply minifying ES2015 code.

like image 924
Leon Revill Avatar asked Dec 05 '15 10:12

Leon Revill


1 Answers

It is now possible to minify ES2015 without transpiling the code. babel minify (previously babili) is a babel preset that does that.

To install do:

npm install --save-dev babel-preset-minify

To use it with gulp you do:

var gulp = require('gulp')
var babel = require('gulp-babel')
gulp.task('default', () => {
  return gulp.src('src/app.js')
  .pipe(babel({presets: ['minify']}))
  .pipe(gulp.dest('dist'))
})
like image 62
Gabriel Furstenheim Avatar answered Nov 20 '22 15:11

Gabriel Furstenheim