-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
55 lines (52 loc) · 1.59 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
* 发布
* ilex
*/
const gulp = require('gulp');
const babel = require('gulp-babel');
const uglify = require('gulp-uglify');
const rename = require('gulp-rename');
const cssnano = require('gulp-cssnano');
const concat = require('gulp-concat');
const del = require('del'); // 清除文件(del)
// 设置默认任务(default)
gulp.task('default', ['clean'], function() {
gulp.start('convertJS', 'convertCSS', 'imagesCopy', 'browserify', 'watch');
});
/////////////////////////////////////
//发布 BEGIN
////////////////////////////////////
// 编译并压缩js
// plugins:['transform-runtime','transform-remove-strict-mode']
gulp.task('compileJs', function(){
return gulp.src('src/**/*.js')
.pipe(babel({
presets: ['es2015', 'react', 'stage-0']
}))
.pipe(uglify())
.pipe(gulp.dest('lib/'));
});
// 合并并压缩css
gulp.task('compileCSS', function(){
return gulp.src('src/**/*.css')
.pipe(concat('app.css'))
.pipe(cssnano())
.pipe(rename(function(path){
path.basename += '.min';
}))
.pipe(gulp.dest('lib/styles'));
});
//复制静态资源到指定目录
gulp.task('compileImg', function(){
return gulp.src(['src/**/*.png', 'src/**/*.jpg', 'src/**/*.gif', 'src/**/*.cur', 'src/**/style/font/**', 'src/**/style/**/*.css'])
.pipe(gulp.dest('lib/'));
});
// 发布之前操作
gulp.task('prepublish', function(done) {
del(['lib'], done);
});
// 执行发布
gulp.task('publish', ['compileJs', 'compileCSS', 'compileImg']);
//////////////////////////////////////////
//发布 END gulp prepublish, gulp publish
/////////////////////////////////////////