-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
85 lines (64 loc) · 1.77 KB
/
gulpfile.babel.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
"use strict";
///////////////////////
// IMPORT NODE MODULES
///////////////////////
import gulp from "gulp"
import browsersync from "browser-sync"
import watch from "gulp-watch"
import sass from "gulp-sass"
import cleancss from "gulp-clean-css"
import autoprefixer from "gulp-autoprefixer"
import rename from "gulp-rename"
import uglify from "gulp-uglify"
///////////////////////
// TASK - BROWSER SYNC
///////////////////////
const browserSync = browsersync.create();
let reload = browserSync.reload;
gulp.task('browser-sync', function() {
browserSync.init({
server: "./"
});
gulp.watch("styles/main.min.css").on("change", reload);
gulp.watch("index.html").on("change", reload);
gulp.watch("scripts/main.min.js").on("change", reload);
});
///////////////////////
// TASK - STYLES
///////////////////////
gulp.task("styles", () => {
return gulp.src("styles/main.scss")
.pipe(sass())
.pipe(autoprefixer())
.pipe(cleancss())
.pipe(rename("main.min.css"))
.pipe(gulp.dest("styles/"))
});
gulp.task("styles2", () => {
return gulp.src("styles/main.scss")
.pipe(sass())
.pipe(rename("main.css"))
.pipe(gulp.dest("styles/"))
});
///////////////////////
// TASK - SCRIPTS
///////////////////////
gulp.task("scripts", () => {
return gulp.src("scripts/main.js")
.pipe(uglify())
.pipe(rename("main.min.js"))
.pipe(gulp.dest("scripts/"))
});
///////////////////////
// TASK - WATCH
///////////////////////
gulp.task("watch", () => {
gulp.watch("styles/main.scss", ["styles"]);
gulp.watch("styles/main.scss", ["styles2"]);
gulp.watch("index.html");
gulp.watch("scripts/main.js", ["scripts"]);
});
///////////////////////
// TASK - DEFAULT
///////////////////////
gulp.task("default", ["watch", "browser-sync", "styles2", "styles", "scripts"]);