-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
executable file
·86 lines (81 loc) · 1.96 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
const gulp = require("gulp");
const babel = require("gulp-babel");
const uglify = require("gulp-uglify");
const browserSync = require("browser-sync").create();
const sass = require("gulp-sass")(require("sass"));
const autoprefixer = require("gulp-autoprefixer");
const notifier = require("node-notifier");
const path = require("path");
let sassPaths = [];
/* SASS */
gulp.task(
"sass",
gulp.parallel([], () => {
return gulp
.src("assets/scss/*.scss")
.pipe(
sass({
includePaths: sassPaths,
outputStyle: "compressed",
})
)
.on("error", function (e) {
sass.logError;
console.log("ERROR", e);
notifier.notify({
title: "Error",
message: "Could not compile scss 🤬",
});
})
.pipe(autoprefixer())
.pipe(gulp.dest("public/css"))
.pipe(browserSync.stream());
})
);
/* Babel */
gulp.task(
"babel",
gulp.parallel([], () => {
return gulp
.src(["assets/js/**/*.js"])
.pipe(
babel({
presets: ["env"],
})
)
.on("error", function (e) {
notifier.notify({
title: "Error",
message: "Could not compile js 🤯",
icon: path.join(__dirname, "logo.png"),
});
console.log("ERROR", e);
this.emit("end");
})
.pipe(uglify())
.pipe(gulp.dest("public/js"));
})
);
/* BrowserSync */
gulp.task(
"browser-sync",
gulp.series([], () => {
// browserSync.init({
// open: 'external',
// host: 'greenpeace-leads.test',
// proxy: 'greenpeace-leads.test',
// port: 3000,
// https: true,
// })
})
);
/* Defalut */
gulp.task(
"default",
gulp.parallel(["browser-sync"], (done) => {
gulp.watch(["assets/scss/**/*.scss"], gulp.series("sass"));
gulp.watch(["assets/js/**/*.js", "!js/dist/**/*.js"], gulp.series("babel"));
// gulp.watch('**/*.php').on('change', browserSync.reload)
done();
})
);