-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.mjs
57 lines (47 loc) · 1.42 KB
/
gulpfile.mjs
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
// From https://dev.to/salttechno/how-to-setup-tailwind-css-with-postcss-browsersync-1j41
import gulp from "gulp";
const { watch, series, src, dest } = gulp;
import BrowserSync from "browser-sync";
import postcss from "gulp-postcss";
import imagemin from "gulp-imagemin";
const browserSync = BrowserSync.create();
// Task for compiling our CSS files using PostCSS
gulp.task("css", () => {
});
function cssTask() {
return src("./src/*.css") // read .css files from ./src/ folder
.pipe(postcss()) // compile using postcss
.pipe(dest("./assets/css")) // paste them in ./assets/css folder
.pipe(browserSync.stream());
}
// Task for minifying images
function imageminTask() {
return src("./assets/images/*")
.pipe(imagemin())
.pipe(dest("./assets/images"));
}
// Serve from browserSync server
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(["./**/*.html", "./src/*.css"], series(cssTask, browsersyncReload));
watch(["./assets/images/*"], series(imageminTask, browsersyncReload));
}
// Default Gulp Task
export default series(cssTask, browsersyncServe, watchTask);
export {
cssTask as css,
imageminTask as images
};