-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathgulpfile.js
65 lines (51 loc) · 1.36 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
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 origin = 'src';
const destination = 'build';
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}/css/animate.css`]).pipe(dest(`${destination}/css`));
src(`${origin}/css/style.scss`)
.pipe(sass({
outputStyle: 'compressed'
}))
.pipe(dest(`${destination}/css`));
cb();
}
function js(cb) {
src(`${origin}/js/lib/**/*.js`).pipe(dest(`${destination}/js/lib`));
src(`${origin}/js/script.js`)
.pipe(babel({
presets: ['@babel/env']
}))
.pipe(dest(`${destination}/js`));
cb();
}
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.default = series(clean, parallel(html, css, js), server, watcher);