-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.babel.js
79 lines (67 loc) · 2.06 KB
/
gulpfile.babel.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
79
import gulp from 'gulp';
import pug from 'gulp-pug';
import webserver from 'gulp-webserver';
import del from 'del';
import image from 'gulp-image';
import dartSass from 'sass';
import gulpSass from 'gulp-sass';
import autoprefixer from 'gulp-autoprefixer';
import csso from 'gulp-csso';
import browserify from 'gulp-bro';
import babelify from 'babelify';
import pages from 'gulp-gh-pages';
import favicons from 'gulp-favicons';
const sass = gulpSass(dartSass);
const clean = () => del(['dist', '.publish']);
const html = () => gulp.src('src/index.pug').pipe(pug()).pipe(gulp.dest('dist'));
const img = () => gulp.src('src/img/*').pipe(image()).pipe(gulp.dest('dist/img'));
const css = () =>
gulp
.src('src/scss/style.scss')
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer())
.pipe(csso())
.pipe(gulp.dest('dist/css'));
const js = () =>
gulp
.src('src/js/main.js')
.pipe(
browserify({
debug: process.env.NODE_ENV === 'development',
transform: [
babelify.configure({ presets: ['@babel/preset-env'] }),
['uglifyify', { global: true }],
],
}),
)
.pipe(gulp.dest('dist/js'));
const favicon = () =>
gulp
.src('src/img/favicon.svg')
.pipe(
favicons({
html: 'index.html',
icons: {
favicons: true,
android: false,
appleIcon: false,
appleStartup: false,
windows: false,
yandex: false,
},
}),
)
.pipe(gulp.dest('dist/favicons'));
const ws = () => gulp.src('dist').pipe(webserver({ livereload: true }));
const publish = () => gulp.src('dist/**/*').pipe(pages());
const watch = () => {
gulp.watch('src/**/*.pug', html);
gulp.watch('src/**/*.scss', css);
gulp.watch('src/**/*.js', js);
};
const prepare = gulp.parallel(clean);
const assets = gulp.parallel(html, css, js, img, favicon);
const live = gulp.parallel(ws, watch);
export const build = gulp.series(prepare, assets);
export const dev = gulp.series(build, live);
export const deploy = gulp.series(build, publish, clean);