-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
gulpfile.js
60 lines (49 loc) · 1.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
const gulp = require('gulp');
const htmlmin = require('gulp-htmlmin');
const merge = require('gulp-merge');
const concat = require('gulp-concat');
const cssmin = require('gulp-clean-css');
const jsmin = require('gulp-uglify-es').default;
const wrapper = require('gulp-wrapper');
const Markers = require('gulp-markers');
const markers = new Markers();
markers.addMarker({
tag : 'js-removal',
re : /<\/?script[^>]*>/,
replace : e => ''
});
markers.addMarker({
tag : 'css-removal',
re : /<link rel="stylesheet"[^>]*>/,
replace : e => ''
});
markers.addMarker({
tag : 'title-removal',
re : /<title>[^<]+<\/title>/,
replace : e => ''
});
gulp.task( 'html', e => {
return merge(
gulp
.src('css/dashboard.css')
.pipe(cssmin({}))
.pipe(wrapper({ header : '<style>', footer : '</style>' })),
gulp
.src('dashboard.html')
.pipe(markers.replaceMarkers())
.pipe(htmlmin({ collapseWhitespace : true, removeComments : true })),
gulp
.src('js/request.js')
.pipe(jsmin())
.pipe(wrapper({ header : '<script>', footer : '</script>' })),
gulp
.src('js/portal.js')
.pipe(jsmin())
.pipe(wrapper({ header : '<script>', footer : '</script>' })),
gulp
.src('js/dashboard.js')
.pipe(jsmin())
.pipe(wrapper({ header : '<script>', footer : '</script>' }))
).pipe(concat('dashboard.html')).pipe(gulp.dest('build'));
} );
gulp.task( 'default', gulp.series('html') );