-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
62 lines (56 loc) · 1.68 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
const gulp = require("gulp");
const babel = require("gulp-babel");
const sass = require("gulp-sass");
const sourcemaps = require("gulp-sourcemaps");
const autoprefixer = require("gulp-autoprefixer");
const browserSync = require("browser-sync");
const reload = browserSync.reload;
const concat = require("gulp-concat");
sass.compiler = require("node-sass");
gulp.task('babel', () =>
gulp.src('js/*.js')
.pipe(sourcemaps.init())
.pipe(babel({
presets: ['@babel/env']
}))
.pipe(concat('all.js'))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('.'))
.pipe(reload({ stream: true }))
);
gulp.task("browser-sync", function() {
const files = ["./scss/*.scss", "./*.php", "./js/*.js",];
browserSync.init(files, {
proxy: "http://newtheme:81",
notify: true
});
gulp.watch("./scss/**/*.scss", gulp.series(css));
gulp.watch("./js/*.js"), gulp.series("babel");
gulp.watch("./*.php").on("change", browserSync.reload);
});
const css = function() {
return gulp
.src("./scss/main.scss")
.pipe(sourcemaps.init())
.pipe(
sass({
outputStyle: "compressed"
}).on("error", sass.logError)
)
.pipe(autoprefixer())
.pipe(sourcemaps.write())
.pipe(concat("style.css"))
.pipe(gulp.dest("./"))
.pipe(reload({ stream: true }));
};
const watch = function(cb) {
gulp.watch("./scss/**/*.scss", gulp.series(css));
gulp.watch("./js/*.js"), gulp.series("babel");
gulp.watch("./*.php").on("change", browserSync.reload);
cb();
};
exports.css = css;
exports.watch = watch;
exports.default = gulp.series(css, "babel", watch, "browser-sync");
// gulp.series // one by one
// gulp.parallel // altogether