-
Notifications
You must be signed in to change notification settings - Fork 21
/
gulpfile.js
53 lines (46 loc) · 1.45 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
const gulp = require('gulp');
const sass = require('gulp-sass')(require('sass'));
const gutil = require('gulp-util');
const uglify = require('gulp-uglifyjs');
const minifyHTML = require('gulp-minify-html');
const connect = require('gulp-connect');
const paths = {
caniuseEmbed: "src/caniuse-embed.js",
embedStyle: "src/embed/scss/style.scss",
embedScript: "src/embed/script.js",
embedHTML: "src/embed/index.html"
};
function script() {
return gulp.src(paths.caniuseEmbed)
.pipe(uglify('caniuse-embed.min.js'))
.pipe(gulp.dest('public'))
.pipe(gulp.src(paths.embedScript))
.pipe(uglify())
.pipe(gulp.dest('public/embed'));
}
function sassTask() {
return gulp.src(paths.embedStyle)
.pipe(sass({
outputStyle: 'compressed'
})
.on('error', gutil.log))
.pipe(gulp.dest('public/embed'));
}
function minifyHtml() {
return gulp.src(paths.embedHTML)
.pipe(minifyHTML({ empty: true }))
.pipe(gulp.dest('public/embed'));
}
function connectServer() {
return connect.server({
port: 8000
});
}
function watch() {
gulp.watch(paths.caniuseEmbed, script);
gulp.watch(paths.embedScript, script);
gulp.watch("src/embed/scss/*.scss", sassTask);
gulp.watch(paths.embedHTML, minifyHtml);
}
exports.default = gulp.series(script, sassTask, minifyHtml, watch);
exports.full = gulp.series(connectServer, script, sassTask, minifyHtml, watch);