-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
63 lines (53 loc) · 1.44 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
var
gulp = require("gulp"),
rename = require("gulp-rename"),
autoprefixer = require("gulp-autoprefixer"),
sourcemaps = require("gulp-sourcemaps"),
uglify = require("gulp-uglify"),
browserSync = require("browser-sync").create(),
sass = require("gulp-sass");
function livereload(done){
browserSync.init({
server: {
baseDir: "./"
},
port: 3000
});
done();
}
function browserReload(done){
browserSync.reload();
done();
}
function build(done){
gulp.src("./scss/**/*.scss")
.pipe(sourcemaps.init())
.pipe(sass({
errorLogToConsole: true,
outputStyle: "compressed"
}))
.on("error", console.error.bind(console))
.pipe(rename({suffix: ".min"}))
.pipe(sourcemaps.write("./"))
.pipe(gulp.dest("./css/"))
.pipe(browserSync.stream());
done();
}
function jsBuild(done){
gulp.src('./js/**/main.js')
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(rename({suffix: ".min"}))
.pipe(sourcemaps.write("./"))
.pipe(gulp.dest("./js/"))
.pipe(browserSync.stream());
done();
}
function watch(){
gulp.watch("./scss/**/*.scss", build);
gulp.watch("./*.html", browserReload);
gulp.watch("./js/**/main.js", jsBuild);
gulp.watch("php/**/*.php", browserReload);
}
gulp.task("default", gulp.parallel(watch, livereload));
gulp.task(livereload);