gulp压缩文件最简示例

  • Post author:
  • Post category:其他


安装gulp-uglify

作为项目的开发依赖即可

$ npm gulp-uglify --save-dev

压缩js文件

gulpfile.js

const gulp = require('gulp');
const uglify = require('gulp-uglify');

gulp.task('uglifyjs', function(){
    gulp.src('src/js/**/*.js')
        .pipe(uglify())
        .pipe(gulp.dest('dist/js'));
});

执行gulp

$ gulp uglifyjs

转载于:https://www.cnblogs.com/xiaoyucoding/p/7224263.html