参考资料
https://www.cnblogs.com/libin-1/p/5965014.html
https://www.cnblogs.com/2050/p/4198792.html
https://github.com/mikrofusion/gulp-obfuscate
一、安装node.js
二、安装gulp
npm install -g gulp
三、安装插件
使用gulp-uglify
安装:npm install --save-dev gulp-uglify
用来压缩js文件,使用的是uglify引擎
var gulp = require('gulp'),
uglify = require("gulp-uglify"),
obfuscate = require('gulp-obfuscate');
gulp.task('minify-js', function () {
console.log('one is done');
gulp.src('test.js') // 要压缩的js文件
.pipe(obfuscate({ replaceMethod: obfuscate.ZALGO }))
.pipe(uglify()) //使用uglify进行压缩,更多配置请参考:
.pipe(gulp.dest('test2.js')); //压缩后的路径
console.log('two is done');
});