-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
111 lines (91 loc) · 1.79 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import gulp from 'gulp';
import htmlmin from 'gulp-htmlmin';
import postcss from 'gulp-postcss';
import autoprefixer from 'autoprefixer';
import csso from 'postcss-csso';
import babel from 'gulp-babel';
import terser from 'gulp-terser';
import del from 'del';
import sync from 'browser-sync';
// HTML
export const html = () => {
return gulp.src('src/index.html')
.pipe(htmlmin({
collapseWhitespace: true,
removeComments: true
}))
.pipe(gulp.dest('build'))
.pipe(sync.stream());
};
// Styles
export const styles = () => {
return gulp.src('src/css/style.css')
.pipe(postcss([
autoprefixer,
csso
]))
.pipe(gulp.dest('build/css'))
.pipe(sync.stream())
};
// Scripts
export const scripts = () => {
return gulp.src('src/js/main.js')
.pipe(babel({
presets: ['@babel/preset-env']
}))
.pipe(terser())
.pipe(gulp.dest('build/js'))
.pipe(sync.stream())
};
// Copy
export const copy = () => {
return gulp.src([
'src/fonts/**/*',
'src/skype.svg',
], {
base: 'src'
})
.pipe(gulp.dest('build'))
.pipe(sync.stream({ once: true }))
};
// Copy media for test
export const copyMedia = () => {
return gulp.src('media/*')
.pipe(gulp.dest('build/media'))
}
// Server
export const server = () => {
sync.init({
server: 'build/',
ui: false,
notify: false,
cors: true,
})
};
// Watch
export const watch = () => {
gulp.watch('src/*.html', html);
gulp.watch('src/css/*.css', styles);
gulp.watch('src/js/*.js', scripts);
};
// Clean
export const clean = () => del('build');
// Build
export const build = gulp.series(
clean,
gulp.parallel(
html,
styles,
scripts,
copy
)
);
// Default
export default gulp.series(
build,
copyMedia,
gulp.parallel(
watch,
server
)
);