forked from SupremeTechnopriest/react-idle-timer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
88 lines (70 loc) · 1.7 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/**
* gulpfile.js
* Build Automation
*
*/
var path = require('path'),
gulp = require('gulp'),
gutil = require('gulp-util'),
webpack = require('webpack'),
WebpackDevServer = require('webpack-dev-server'),
WebpackDevConfig = require('./webpack.dev.config'),
eslint = require('gulp-eslint'),
del = require('del'),
babel = require('gulp-babel'),
shell = require('gulp-shell'),
uglify = require('gulp-uglify');
///////////
// CLEAN //
///////////
gulp.task('del', function(cb) {
del([
'./build'
], function() {
process.exit();
});
});
//////////
// Test //
//////////
//////////
// LINT //
//////////
gulp.task('lint', function() {
return gulp.src(['src/js/**/**/*.js'])
.pipe(eslint())
.pipe(eslint.format());
});
////////////////
// Dev Build //
////////////////
gulp.task("build-dev", function(callback) {
new WebpackDevServer(webpack(WebpackDevConfig), {
watch: true,
hot: true,
contentBase: path.resolve(__dirname, 'examples'),
historyApiFallback: true
}).listen(3002, 'localhost', function(err, result) {
if (err) {
console.log(err);
}
console.log('Examples dev server running at localhost:3002');
});
});
//////////////////
// Distribution //
//////////////////
gulp.task('build', function(callback) {
return gulp.src(['./src/index.js', '!./src/__tests__/*.js'])
.pipe(babel())
.pipe(uglify())
.pipe(gulp.dest('./build'));
});
/////////////////////
// Runnable Tasks //
/////////////////////
gulp.task('default', ['build-dev']);
gulp.task('clean', ['del']);
gulp.task('test', ['lint'], function() {
process.exit();
});