-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
46 lines (40 loc) · 1.15 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
const { watch, series, src, dest } = require("gulp")
var browserSync = require("browser-sync").create()
var postcss = require("gulp-postcss")
const imagemin = require("gulp-imagemin")
const cleanCSS = require("gulp-clean-css")
// Task for compiling our CSS files using PostCSS
function cssTask(cb) {
return src("./src/*.css") // read .css files from ./src/ folder
.pipe(postcss()) // compile using postcss
.pipe(cleanCSS({ compatibility: "ie8" }))
.pipe(dest("./assets/css")) // paste them in ./assets/css folder
.pipe(browserSync.stream())
cb()
}
// Task for minifying images
function imageminTask(cb) {
return src("./assets/images/*").pipe(imagemin()).pipe(dest("./assets/images"))
cb()
}
function browsersyncServe(cb) {
browserSync.init({
server: {
baseDir: "./",
},
})
cb()
}
function browsersyncReload(cb) {
browserSync.reload()
cb()
}
// Watch Files & Reload browser after tasks
function watchTask() {
watch("./**/*.html", browsersyncReload)
watch(["./src/*.css"], series(cssTask, browsersyncReload))
}
// Default Gulp Task
exports.default = series(cssTask, browsersyncServe, watchTask)
exports.css = cssTask
exports.images = imageminTask