-
Notifications
You must be signed in to change notification settings - Fork 24
/
gulpfile.js
117 lines (96 loc) · 2.55 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
109
110
111
112
113
114
115
116
117
var pkg = require('./package.json'),
pug = require('gulp-pug'),
gulp = require('gulp'),
less = require('gulp-less'),
clean = require('gulp-clean-css'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
header = require('gulp-header'),
jshint = require('gulp-jshint'),
stylish = require('jshint-stylish'),
browSync = require('browser-sync').create();
var banner = ['/**',
' * Vanilla Javascript Carousel v<%= pkg.version %>',
' * <%= pkg.homepage %>',
' */',
''].join('\n');
gulp.task('lint', function(done) {
gulp.src('./src/javascript/*.js')
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter(stylish));
done();
});
gulp.task('script', gulp.series('lint', function(done) {
gulp.src(['./src/javascript/vanilla-js-carousel.js'])
.pipe(uglify())
.pipe(header(banner, {
pkg: pkg
}))
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('./dist'))
.pipe(gulp.dest('./docs/javascript'));
done();
}));
gulp.task('script-live', gulp.series('lint', function(done) {
gulp.src(['./src/javascript/vanilla-js-carousel.js'])
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('./dist'))
.pipe(browSync.stream());
done();
}));
gulp.task('markup', function(done) {
gulp.src('./src/index.pug')
.pipe(pug({
pretty: true
}))
.pipe(gulp.dest('./dist'));
done();
});
gulp.task('markup-live', function(done) {
gulp.src('./src/index.pug')
.pipe(pug())
.pipe(gulp.dest('./dist'))
.pipe(browSync.stream());
done();
});
gulp.task('docs-styles', function(done) {
gulp.src('./docs/styles/*.less')
.pipe(less())
.pipe(clean({
compatibility: 'ie9'
}))
.pipe(gulp.dest('./docs/styles'));
done();
});
gulp.task('styles', gulp.series('docs-styles', function(done) {
gulp.src('./src/styles/*.less')
.pipe(less())
.pipe(gulp.dest('./dist'))
.pipe(gulp.dest('./docs/styles'))
.pipe(browSync.stream());
done();
}));
gulp.task('styles-live', function(done) {
gulp.src('./src/styles/*.less')
.pipe(less())
.pipe(gulp.dest('./dist'))
.pipe(browSync.stream());
done();
});
// static Server + watching less/html files
gulp.task('serve', gulp.series('script-live', 'markup-live', 'styles-live', 'lint', function() {
browSync.init({
server: './dist',
online: false
});
gulp.watch('src/styles/*.less', gulp.series('styles'));
gulp.watch('src/*.pug', gulp.series('markup'));
gulp.watch('src/javascript/*.js', gulp.series('script'));
// done();
}));
gulp.task('default', gulp.series('script', 'markup', 'styles', 'docs-styles', 'lint'));
gulp.task('live', gulp.series('serve'));