-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
78 lines (63 loc) · 1.59 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 {src, dest, series, parallel, watch} = require('gulp');
const del = require('del');
const browserSync = require('browser-sync').create();
const sass = require('gulp-sass');
const babel= require('gulp-babel');
const imagemin = require('gulp-imagemin');
const origin = 'src';
const destination = 'dist';
sass.compiler = require('node-sass');
async function clean(cb) {
await del(destination);
cb();
}
function html(cb) {
src(`${origin}/**/*.html`).pipe(dest(destination));
cb();
}
function css(cb) {
src(`${origin}/scss/styles.scss`)
.pipe(sass({
outputStyle: 'compressed'
}))
.pipe(dest(`${destination}/css`));
cb();
}
function js(cb) {
src(`${origin}/js/script.js`)
.pipe(babel({
presets: ['@babel/env']
}))
.pipe(dest(`${destination}/js`));
cb();
}
function img(cb) {
src(`${origin}/img/*`)
.pipe(imagemin())
.pipe(dest(`${destination}/img`))
cb()
}
async function copyfontawesomeWebfontsTask() {
return gulpif(
fileExists.sync(fontawesomeWebfont),
src([webFontsPath]).pipe(dest(distWebfonts))
);
}
function watcher(cb) {
watch(`${origin}/**/*.html`).on('change', series(html, browserSync.reload))
watch(`${origin}/**/*.scss`).on('change', series(css, browserSync.reload))
watch(`${origin}/**/*.js`).on('change', series(js, browserSync.reload))
cb();
}
function server(cb) {
browserSync.init({
notify: false,
open: false,
server: {
baseDir: destination
}
})
cb();
}
exports.prod = series(clean, parallel(html, css, js, img));
exports.default = series(clean, parallel(html, css, js, img), server, watcher);