gulp-uglify
1.1、gulp-uglify简介

gulp-uglify插件用来压缩JavaScript代码的,以减少文件大小,从而加快网络传输。

gulp-uglifyGitHub上的网址:https://github.com/terinjokes/gulp-uglify

gulp-uglifynpm registry上的网址:https://www.npmjs.com/package/gulp-uglify

1.2、通过包管理器安装gulp-uglify
包管理器安装命令
npmnpm install gulp-uglify --save-dev
yarnyarn add gulp-uglify -dev
1.3、使用gulp-uglify
const gulp   = require('gulp');
const uglify = require('gulp-uglify');

gulp.task("default", function () {
    gulp.src('./src/public/js/**/*.js')
        .pipe(uglify({mangle: true}))
        .pipe(gulp.dest('./build/public/js/'));
});