forked from forkineye/ESPixelStick
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
97 lines (87 loc) · 2.61 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
/* Requires */
var gulp = require('gulp');
var plumber = require('gulp-plumber');
var concat = require('gulp-concat');
var htmlmin = require('gulp-htmlmin');
var cleancss = require('gulp-clean-css');
var uglifyjs = require('gulp-uglify');
var gzip = require('gulp-gzip');
var del = require('del');
var markdown = require('gulp-markdown-github-style');
var rename = require('gulp-rename');
/* HTML Task */
gulp.task('html', function() {
return gulp.src(['html/*.html', 'html/*.htm'])
.pipe(plumber())
.pipe(htmlmin({
collapseWhitespace: true,
removeComments: true,
minifyCSS: true,
minifyJS: true}))
.pipe(gzip())
.pipe(gulp.dest('data/www'));
});
/* CSS Task */
gulp.task('css', function() {
return gulp.src(['html/css/bootstrap.css', 'html/style.css'])
.pipe(plumber())
.pipe(concat('esps.css'))
.pipe(cleancss())
.pipe(gzip())
.pipe(gulp.dest('data/www'));
});
/* JavaScript Task */
gulp.task('js', function() {
return gulp.src(['html/js/jquery*.js', 'html/js/bootstrap.js', 'html/js/jqColorPicker.js', 'html/script.js'])
.pipe(plumber())
.pipe(concat('esps.js'))
.pipe(uglifyjs())
.pipe(gzip())
.pipe(gulp.dest('data/www'));
});
/* Image Task */
gulp.task('image', function() {
return gulp.src(['html/**/*.png', 'html/**/*.ico'])
.pipe(plumber())
.pipe(gulp.dest('data/www'));
});
/* Clean Task */
gulp.task('clean', function() {
return del(['data/www/*']);
});
/* Markdown to HTML Task */
gulp.task('md', function(done) {
gulp.src('README.md')
.pipe(plumber())
.pipe(rename('ESPixelStick.html'))
.pipe(markdown())
.pipe(gulp.dest('dist'));
gulp.src('Changelog.md')
.pipe(plumber())
.pipe(rename('Changelog.html'))
.pipe(markdown())
.pipe(gulp.dest('dist'));
gulp.src('dist/README.md')
.pipe(plumber())
.pipe(rename('README.html'))
.pipe(markdown())
.pipe(gulp.dest('dist'));
done();
});
/* Travis specific stuff */
gulp.task('travis', function(done) {
gulp.src(['travis/travis.md', 'dist/README.md'])
.pipe(plumber())
.pipe(concat('README.html'))
.pipe(markdown())
.pipe(gulp.dest('dist'));
done();
});
/* Watch Task */
gulp.task('watch', function() {
gulp.watch('html/*.html', gulp.series('html'));
gulp.watch('html/**/*.css', gulp.series('css'));
gulp.watch('html/**/*.js', gulp.series('js'));
});
/* Default Task */
gulp.task('default', gulp.series(['clean', 'html', 'css', 'js', 'image']));