This repository has been archived by the owner on Dec 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
84 lines (71 loc) · 1.86 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
// Dependencies
var gulp = require('gulp'),
gutil = require('gulp-util'),
rename = require('gulp-rename'),
inlineSrc = require('gulp-inline-source'),
inlineCss = require('gulp-inline-css'),
minifyCss = require('gulp-minify-inline'),
minifyHtml = require('gulp-minify-html'),
watch = require('gulp-watch'),
liveReload = require('gulp-livereload');
// Configuration
var path = './template-*/',
// Source and options for gulp.src
source = path + 'index.html',
options = {
base: './'
},
// File basename after rename (gulp-rename)
filename = 'compiled',
// Compile destination for gulp.dest
destination = './',
// List of watched files
watched = [
source,
path + '*.css'
];
// Compile HTML & CSS
gulp.task('compile', function() {
return gulp.src(source, options)
// gulp-inline-source
// Replace <link inline /> to <style> tags,
// inline source CSS
.pipe(inlineSrc({
compress: false
// swallowErrors: true
}))
// gulp-inline-css
// Inline CSS using style attribute
.pipe(inlineCss({
applyStyleTags: false,
removeStyleTags: false,
applyLinkTags: true,
removeLinkTags: true
}))
// gulp-minify-inline
// Minify CSS
.pipe(minifyCss({
js: false,
css: {
advanced: false
}
}))
// gulp-minify-html
// Minify HTML
.pipe(minifyHtml({
conditionals: true,
spare: true,
quotes: true
}))
// Finishing up
.pipe(rename({basename: filename}))
.pipe(gulp.dest(destination))
.pipe(liveReload());
});
// Watch changes, compile & live reload
gulp.task('watch', function() {
liveReload.listen();
gulp.watch(watched, ['compile']);
});
// Default Gulp task
gulp.task('default', ['compile', 'watch']);