forked from flatpickr/flatpickr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
73 lines (61 loc) · 1.64 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
const gulp = require("gulp"),
babel = require("gulp-babel"),
cssmin = require("gulp-cssmin"),
lint = require("gulp-eslint"),
livereload = require("gulp-livereload"),
plumber = require("gulp-plumber"),
rename = require("gulp-rename"),
stylus = require("gulp-stylus"),
uglify = require("gulp-uglify");
const paths = {
style: "./src/style/flatpickr.styl",
script: "./src/flatpickr.js",
themes: "./src/style/themes/*.styl"
};
function get_script_stream(){
return gulp.src(paths.script)
.pipe(plumber())
.pipe(lint())
.pipe(lint.format())
.pipe(babel({presets: ['es2015']}));
}
gulp.task('script', function(done){
get_script_stream().pipe(gulp.dest('dist'));
get_script_stream()
.pipe(uglify({preserveComments: 'license'}))
.pipe(rename({ suffix: '.min'}))
.pipe(gulp.dest('dist'))
.pipe(livereload());
done();
});
gulp.task('style', function(done){
gulp.src(paths.style)
.pipe(plumber())
.pipe(stylus())
.pipe(cssmin()).on('error', errorHandler)
.pipe(rename({ suffix: '.min'}))
.pipe(gulp.dest('dist'))
.pipe(livereload());
done();
});
gulp.task('themes', function(done){
gulp.src(paths.themes)
.pipe(plumber())
.pipe(stylus())
.pipe(cssmin()).on('error', errorHandler)
.pipe(rename({ prefix: 'flatpickr.',suffix: '.min'}))
.pipe(gulp.dest('dist'))
.pipe(livereload());
done();
});
gulp.task('watch', function(done) {
livereload.listen();
gulp.watch('./src/style/**/*.styl', gulp.parallel('style', 'themes'));
gulp.watch(paths.script, gulp.series('script'));
done();
});
// Handle the error
function errorHandler (error) {
console.log(error.toString());
}
gulp.task('default', gulp.parallel('script', 'style', 'themes', 'watch'));