gulp
1. 安装
npm install --g gulp
2. 初始化
npm init
3. 新建gulpfile.js
var gulp = require('gulp'),
clean = require('gulp-clean'),
uglify = require('gulp-uglify'),
minify = require('gulp-minify-css');
gulp.task('before-clean', function(cb){
return gulp.src('build').pipe(clean());
});
gulp.task('copy-file', ['before-clean'], function(){
return gulp.src(['web/**', '!web/static/js/*.js', '!web/static/css/*.css'])
.pipe(gulp.dest('build/'));
});
gulp.task('js-mini', ['before-clean'], function(){
return gulp.src('web/static/js/*.js')
.pipe(uglify()).pipe(gulp.dest('build/static/js'));
});
gulp.task('css-mini', ['before-clean'], function(){
return gulp.src('web/static/css/*.css')
.pipe(minify()).pipe(gulp.dest('build/static/css'));
});
gulp.task('build', ['copy-file', 'js-mini', 'css-mini']);
gulp.task('default', ['build']);
4. 运行
gulp