-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
71 lines (57 loc) · 1.6 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**
* @file gulpfile.js
* @author cxtom(cxtom2010@gmail.com)
*/
var gulp = require('gulp');
var del = require('del');
var connect = require('gulp-connect');
var stylus = require('gulp-stylus');
var webpack = require('gulp-webpack');
var babel = require('gulp-babel');
var nib = require('nib');
var webpackConfig = require('./webpack.config.js');
var babelHelpers = require('./tool/gulpBabelExternalHelper');
var port = process.env.PORT || 8080;
var reloadPort = process.env.RELOAD_PORT || 35729;
gulp.task('clean', function () {
del(['build']);
});
gulp.task('release-clean', function () {
del(['lib']);
});
gulp.task('build', function () {
return gulp.src('./example/common/App.js')
.pipe(webpack(webpackConfig))
.pipe(gulp.dest('build/'));
});
gulp.task('release', function () {
return gulp.src(['./src/*.js', './src/**/*.js'])
.pipe(babel())
.pipe(babelHelpers())
.pipe(gulp.dest('lib/'));
});
gulp.task('serve', function () {
connect.server({
port: port,
livereload: {
port: reloadPort
}
});
});
gulp.task('stylus', function () {
gulp.src('./example/main.styl')
.pipe(stylus({
use: nib()
}))
.pipe(gulp.dest('build/'))
.pipe(connect.reload());
});
gulp.task('reload-js', function () {
return gulp.src('./build/*.js')
.pipe(connect.reload());
});
gulp.task('watch', function () {
gulp.watch(['./build/*.js'], ['reload-js']);
});
gulp.task('default', ['clean', 'build', 'stylus', 'serve', 'watch']);
gulp.task('commonjs', ['release-clean', 'release']);