我有一只小松鼠 2020-02-29
var gulp = require('gulp'); var concat = require('concat'); var uglify = require('uglify'); gulp.task('js', function() { gulp.src(['./js/index.js', './js/nav.js']) //将文件合并成一个index.js文件 .pipe(concat('index.js')) // 将文件进行丑化处理 .pipe(uglify({ 'toplevel':true, 'compress': { 'drop_console': true, 'drop_debugger': true, } })) //为文件进行重命名 .pipe(rename({'suffix': '.min'})) .pipe(gulp.dest('./dist/js/')) });
var gulp = require('gulp'), uglify = require('gulp-uglify'), rename = require('gulp-rename'), concat = require('gulp-concat'), pipeline = require('readable-stream').pipeline; gulp.task('js02', function() { return pipeline( gulp.src(['./js/index.js','./js/nav.js']), concat('index.js'), //压缩主要是依靠uglify()函数; uglify(), rename({ 'suffix': '.min', }), gulp.dest('./dist/js/') ) });