-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
71 lines (62 loc) · 1.42 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
// Load plugins
const autoprefixer = require('autoprefixer');
const browsersync = require('browser-sync').create();
const del = require('del');
const gulp = require('gulp');
const postcss = require('gulp-postcss');
const sass = require('gulp-sass');
const concat = require('gulp-concat');
// paths
const paths = {
src: 'src/',
srcHTML: 'src/**/*.html',
srcSCSS: 'src/**/index.scss',
dist: 'dist/',
};
// BrowserSync
function browserSync(done) {
browsersync.init({
server: {
baseDir: './' + paths.dist
},
port: 3000
});
}
// HTML task
function html() {
return gulp
.src(paths.srcHTML)
.pipe(gulp.dest(paths.dist))
.pipe(browsersync.stream());
}
// CSS task
function css() {
return gulp
.src(paths.srcSCSS)
.pipe(sass({ outputStyle: 'compressed' }))
.pipe(postcss([autoprefixer()]))
.pipe(concat('style.css'))
.pipe(gulp.dest(paths.dist))
.pipe(browsersync.stream());
}
// image task
function image() {
return gulp
.src(`${paths.src}assets/**/*`)
.pipe(gulp.dest(`${paths.dist}assets/`));
}
// Clean assets
function clean() {
return del([paths.dist]);
}
// Watch files
function watchFiles() {
gulp.watch(paths.srcHTML, html);
gulp.watch(paths.srcSCSS, css);
}
// define complex tasks
const build = gulp.series(clean, gulp.parallel(css, html, image));
const watch = gulp.parallel(watchFiles, browserSync);
// export tasks
exports.build = build;
exports.watch = watch;