-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
54 lines (50 loc) · 1.48 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
const { src, dest, watch, series } = require('gulp');
const sass = require('gulp-sass')(require('sass'));
const prefix = require('gulp-autoprefixer');
const minify = require('gulp-clean-css');
const concat = require('gulp-concat');
const htmlmin = require('gulp-htmlmin');
const terser = require('gulp-terser');
const browserSync = require('browser-sync').create();
function compileScss() {
return src('src/styles/**/*.scss')
.pipe(sass())
.pipe(prefix('last 2 versions'))
.pipe(minify())
.pipe(concat('styles.min.css'))
.pipe(dest('src/styles'))
.pipe(browserSync.stream());
}
function copyHtml() {
return src('src/index.html')
.pipe(
htmlmin({
removeComments: true,
}),
)
.pipe(dest('build'));
}
function copyJs() {
return src('src/js/*.js').pipe(terser()).pipe(dest('build/js'));
}
function copySvg() {
return src('src/assets/svg/*.svg').pipe(dest('build/assets/svg'));
}
function copyStyles() {
return src('src/styles/*.css').pipe(dest('build/styles'));
}
function copyImage() {
return src('src/assets/raster/*{.jpg.jpeg,png}').pipe(dest('build/assets/raster'));
}
function server() {
browserSync.init({
server: {
baseDir: './src/',
},
});
watch('src/styles/**/*.scss', compileScss);
watch('src/*.html').on('change', browserSync.reload);
watch('src/js/**/*.js').on('change', browserSync.reload);
}
exports.server = series(compileScss, server);
exports.build = series(copyHtml, copyStyles, copySvg, copyJs, copyImage);