-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
108 lines (81 loc) · 1.88 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/**
* gulpfile.js
*
* @author Denis Luchkin-Zhou <denis@ricepo.com>
* @license MIT
*/
const gulp = require('gulp');
const del = require('del');
const yaml = require('gulp-yaml');
const babel = require('gulp-babel');
const eslint = require('gulp-eslint');
const changed = require('gulp-changed');
const sourcemaps = require('gulp-sourcemaps');
/*!
* Load plugin configuration files.
*/
const out = 'lib';
/*!
* Default build target.
*/
gulp.task('default', ['rebuild']);
/*!
* Delete previous builds.
*/
const clean = () => del(`${out}/**`);
gulp.task('clean', clean);
/*!
* Build javascript
*/
const jsBuild = () => gulp
.src('src/**/*.js', { base: 'src' })
.pipe(changed(out))
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError())
.pipe(sourcemaps.init())
.pipe(babel())
.pipe(sourcemaps.write())
.pipe(gulp.dest(out));
gulp.task('build:js', jsBuild);
gulp.task('build:js:re', ['clean'], jsBuild);
/*!
* Build configuration files
*/
const ymlBuild = () => gulp
.src('src/**/*.yml', { base: 'src' })
.pipe(changed(`${out}`))
.pipe(yaml())
.pipe(gulp.dest(`${out}`));
gulp.task('build:yml', ymlBuild);
gulp.task('build:yml:re', ['clean'], ymlBuild);
/*!
* Build misc JSON files
*/
const jsonBuild = () => gulp
.src(['src/**/*.json'])
.pipe(gulp.dest(`${out}`));
gulp.task('build:json', jsonBuild);
gulp.task('build:json:re', ['clean'], jsonBuild);
/*!
* Incremental build (use with watch).
*/
gulp.task('build', [
'build:js',
'build:yml',
'build:json'
]);
gulp.task('rebuild', [
'build:js:re',
'build:yml:re',
'build:json:re'
]);
/*!
* Automatically rebuild on save.
*/
const watch = () => {
gulp.watch('src/**/*.js', ['build:js']);
gulp.watch('src/**/*.yml', ['build:yml']);
gulp.watch('src/**/*.json', ['build:json']);
};
gulp.task('watch', ['rebuild'], watch);