forked from rgalus/sticky-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
94 lines (67 loc) · 1.49 KB
/
gulpfile.babel.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
'use strict';
//
// Gulp
// --------------------------------------------------
/*
* Import gulp modules
*/
import gulp from 'gulp';
import del from 'del';
import babel from 'gulp-babel';
import rename from 'gulp-rename';
import uglify from 'gulp-uglify';
import size from 'gulp-size';
import gzip from 'gulp-gzip';
import browser_sync from 'browser-sync';
/*
* Create browserSync instance
*/
const browserSync = browser_sync.create();
/*
* Clean dist directory
*/
const clean = () => del([ './dist' ]);
export { clean };
/*
* Compile js
*/
export function js() {
return gulp.src('./src/sticky.js')
.pipe(babel())
.pipe(rename('sticky.compile.js'))
.pipe(gulp.dest('./dist/'))
.pipe(size({ title: 'compiled:' }))
.pipe(uglify())
.pipe(size({ title: 'minified:' }))
.pipe(rename('sticky.min.js'))
.pipe(gulp.dest('./dist/'))
.pipe(gzip())
.pipe(size({ title: 'gzipped:' }))
.pipe(gulp.dest('./dist/'));
}
/*
* Serve
*/
export function serve() {
gulp.watch('./src/*.js', gulp.series(js))
gulp.watch('./demo/*.html').on('change', browserSync.reload);
gulp.watch('./dist/*.js').on('change', browserSync.reload);
return browserSync.init({
server: {
baseDir: './',
directory: true,
},
startPath: '/demo/index.html',
});
}
/*
* Builder
*/
const build = gulp.series(clean, js);
export { build };
const server = gulp.series(clean, js, serve);
export { server };
/*
* Export a default task
*/
export default server;