How to connect input to uglify-js harmony in gulp

I want to remove some classes containing JS. This is currently not supported gulp-uglifyas a quality here .

I did.,

npm install uglify-js-harmony --save-dev

as was said in the previous answer, but, in general, new to the interface, I now don’t know how to transfer this source code, as I could, using gulp-uglify.

I have something like this.,

var uglify = require('uglify-js-harmony');

// ...

gulp.task('scripts', function(){
    return gulp.src(bower().concat(jsFiles))            
        .pipe(plumber())
        .pipe(concat('main.min.js'))
        .pipe(uglify())
        .pipe(gulp.dest(dest + 'js'))
        .pipe(reload({stream:true}))
});

... but he gives me my word [17:42:40] TypeError: uglify is not a function, and I don’t understand how to do it. Thank.

+4
source share
1 answer

It’s much easier to use regular gulp-babelin combination with gulp-uglify.,

$ npm install --save-dev gulp-uglify gulp-babel babel-preset-es2015

Then.,

var uglify = require('gulp-uglify'),
    babel  = require('gulp-babel');


// ...

gulp.task('scripts', function(){
    return gulp.src(//... src stuff
        .pipe(babel({ presets: ['es2015']}))
        .pipe(uglify()))
        //... other stuff
});
-1
source

Source: https://habr.com/ru/post/1660333/


All Articles