-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
executable file
·81 lines (72 loc) · 1.86 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
const gulp = require('gulp');
const $ = require('gulp-load-plugins')();
const pkg = require('./package.json');
const banners = require('./config/banners');
const jestConfig = require('./config/jest');
const jsdocConfig = require('./config/jsdoc');
// build
// --
gulp.task('clean', () => {
return gulp
.src(['coverage', 'dist', 'docs'], { allowEmpty: true, read: false })
.pipe($.clean({ force: true }));
});
gulp.task('compile', () => {
return gulp
.src('./src/Core.js')
.pipe(
$.preprocess({
context: { NODE_ENV: 'production' }
})
)
.pipe($.rename(`${pkg.name}.js`))
.pipe($.stripComments())
.pipe($.babel())
.pipe($.header(banners.max))
.pipe(gulp.dest('./dist'));
});
gulp.task('uglify', () => {
return gulp
.src(`./dist/${pkg.name}.js`)
.pipe($.uglify())
.pipe($.header(banners.min))
.pipe($.rename(`${pkg.name}.min.js`))
.pipe(gulp.dest('./dist'));
});
gulp.task('build', gulp.series('clean', 'compile', 'uglify'));
// continuous build
// --
gulp.task(
'watch',
gulp.series('build', () => {
gulp.watch(['./src/**/*.js', '!./src/**/*.test.js'], gulp.series('build'));
})
);
// run unit tests (requires build/'dist' output)
// --
gulp.task('clean:coverage', () => {
return gulp
.src('./coverage', { allowEmpty: true, read: false })
.pipe($.clean({ force: true }));
});
gulp.task(
'test',
gulp.series('clean:coverage', 'build', () => {
return gulp.src('./dist/grindstone.min.js').pipe($.jest.default(jestConfig));
})
);
// generate documentation
// --
gulp.task('clean:jsdoc', () => {
return gulp
.src('./docs', { allowEmpty: true, read: false })
.pipe($.clean({ force: true }));
});
gulp.task(
'jsdoc',
gulp.series('clean:jsdoc', () => {
return gulp
.src(['./test/*.js', './config/*.js', './src/**/*.js'])
.pipe($.jsdoc3(jsdocConfig));
})
);