forked from flatpickr/flatpickr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
59 lines (52 loc) · 1.49 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
const gulp = require("gulp"),
babel = require("gulp-babel"),
cssmin = require("gulp-cssmin"),
lint = require("gulp-jshint"),
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"
};
gulp.task('script', function(){
return gulp.src(paths.script)
.pipe(plumber())
.pipe(lint({
"esversion": 6,
"unused": true
}))
.pipe(lint.reporter('default'))
.pipe(babel({presets: ['es2015']}))
.pipe(uglify({compress: {hoist_funs: false, hoist_vars: false}})).on('error', errorHandler)
.pipe(rename({ suffix: '.min'}))
.pipe(gulp.dest('dist'));
});
gulp.task('style', function(){
return gulp.src(paths.style)
.pipe(plumber())
.pipe(stylus())
.pipe(cssmin()).on('error', errorHandler)
.pipe(rename({ suffix: '.min'}))
.pipe(gulp.dest('dist'));
});
gulp.task('themes', function(){
return gulp.src(paths.themes)
.pipe(plumber())
.pipe(stylus())
.pipe(cssmin()).on('error', errorHandler)
.pipe(rename({ prefix: 'flatpickr.',suffix: '.min'}))
.pipe(gulp.dest('dist'));
});
gulp.task('watch', function(done) {
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'));