-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
42 lines (37 loc) · 911 Bytes
/
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
const { src, dest, watch, series } = require('gulp');
const sass = require('gulp-sass');
const postcss = require('gulp-postcss');
const cssnano = require('cssnano');
const terser = require('gulp-terser');
const browsersync = require('browser-sync').create();
// Sass Task
function scssTask(){
return src('src/assets/sass/style.scss', { sourcemaps: true })
.pipe(sass())
.pipe(postcss([cssnano()]))
.pipe(dest('src/assets/css', { sourcemaps: '.' }));
}
// Browsersync Tasks
function browsersyncServe(cb){
browsersync.init({
server: {
baseDir: './'
}
});
cb();
}
function browsersyncReload(cb){
browsersync.reload();
cb();
}
// Watch Task
function watchTask(){
watch('**/*', browsersyncReload);
watch(['src/assets/sass/**/*.scss'], series(scssTask, browsersyncReload));
}
// Default Gulp task
exports.default = series(
scssTask,
browsersyncServe,
watchTask
);