var gulp = require('gulp'), minifycss = require('gulp-minify-css'), concat = require('gulp-concat'), uglify = require('gulp-uglify'), rename = require('gulp-rename'), del = require('del'); gulp.task('minifycss', function() { return gulp.src('css/*.css') //压缩的文件 .pipe(minifycss()) .pipe(gulp.dest('build/css')) //输出文件夹 //执行压缩 }); gulp.task('minifyjs', function() { return gulp.src('js/*.js') //.pipe(rename({suffix: '.min'})) //rename压缩后的文件名 .pipe(uglify()) //压缩 .pipe(gulp.dest('build/js')); //输出 }); gulp.task('default', ['minifycss', 'minifyjs','watchcss','watchjs'], function() { }); gulp.task('watchcss', function () { gulp.watch('css/*.css', ['minifycss']); }); gulp.task('watchjs', function () { gulp.watch('js/*.js', ['minifyjs']); });