首页 > 代码库 > gulp常用方法

gulp常用方法


var
gulp=require(‘gulp‘), rename=require(‘gulp-rename‘), mincss=require(‘gulp-clean-css‘), uglify=require(‘gulp-uglify‘), watch=require(‘gulp-watch‘), del=require(‘del‘);gulp.task(‘mincss‘,[‘clean‘],function(){ return gulp.src(‘css/**/*.css‘) .pipe(mincss()) .pipe(rename({suffix:‘.min‘})) .pipe(gulp.dest(‘outcss‘));});gulp.task(‘minjs‘,function(){ return gulp.src(‘test/**/*.js‘) .pipe(uglify()) .pipe(rename({suffix:‘.min‘})) .pipe(gulp.dest(‘dist‘));});gulp.task(‘watch‘,function(){ watch([‘css/*.css‘,‘test/**/*.js‘], function(){ gulp.start(‘mincss‘,‘minjs‘); });})gulp.task(‘clean‘,function(cb){ return del([‘outcss/‘, ‘dist/‘], cb);});gulp.task(‘default‘,[‘clean‘],function(){ gulp.start(‘watch‘,‘mincss‘,‘minjs‘);})

 

gulp常用方法