-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
78 lines (68 loc) · 1.65 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
const gulp = require('gulp')
const sass = require('gulp-sass')
const connect = require('gulp-connect')
const concat = require('gulp-concat')
const include = require('gulp-file-include')
const inline = require('gulp-inline-css')
const del = require('rimraf')
function clean(done) {
del.sync('build')
del.sync('dist')
done()
}
function css() {
return gulp.src('src/styles/root.scss')
.pipe(sass().on('error', sass.logError))
.pipe(concat('style.css'))
.pipe(gulp.dest('src/html/after-signup'))
.pipe(connect.reload())
}
function html() {
return gulp.src('src/html/**/*.html')
.pipe(inline({
applyStyleTags: true,
applyLinkTags: true,
removeStyleTags: false,
removeLinkTags: true,
removeHtmlSelectors: true,
}))
.pipe(gulp.dest('dist'))
}
function htmlDev() {
return gulp.src('src/html/**/index.html')
.pipe(include({
prefix: '{{ ',
suffix: ' }}',
basepath: '@file'
}))
.pipe(inline({
applyStyleTags: true,
applyLinkTags: true,
removeStyleTags: false,
removeLinkTags: true,
removeHtmlSelectors: true
}))
.pipe(gulp.dest('build'))
.pipe(connect.reload())
}
function devServer(done) {
connect.server({
port: 8000,
root: 'build',
livereload: true
})
done()
}
function watch() {
gulp.watch('src/styles/*.scss').on('all', gulp.series(css, htmlDev))
gulp.watch('src/html/**/*.html').on('all', gulp.series(htmlDev))
}
gulp.task('dist', gulp.series(
clean,
gulp.parallel(css, html)
))
gulp.task('build', gulp.series(
clean,
gulp.parallel(css, htmlDev)
))
gulp.task('default', gulp.series('build', devServer, watch))