-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
61 lines (55 loc) · 1.6 KB
/
Copy pathgulpfile.js
File metadata and controls
61 lines (55 loc) · 1.6 KB
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
const gulp = require("gulp");
const plumber = require("gulp-plumber");
const rename = require("gulp-rename");
const sass = require("gulp-sass");
const autoPrefixer = require("gulp-autoprefixer");
require("es6-promise").polyfill();
const cssComb = require("gulp-csscomb");
const cmq = require("gulp-merge-media-queries");
const cleanCss = require("gulp-clean-css");
(browserSync = require("browser-sync").create()), (reload = browserSync.reload);
const uglify = require("gulp-uglify-es").default;
const imagemin = require("gulp-imagemin");
gulp.task("scss", function () {
return gulp
.src(["src/scss/**/*.scss"])
.pipe(sass())
.pipe(autoPrefixer())
.pipe(cssComb())
.pipe(cmq({ log: true }))
.pipe(gulp.dest("dist/css"))
.pipe(
rename({
suffix: ".min",
})
)
.pipe(cleanCss())
.pipe(gulp.dest("dist/css"));
});
gulp.task("image", function () {
return gulp.src("src/img/*").pipe(imagemin()).pipe(gulp.dest("dist/img"));
});
gulp.task("js", function () {
return gulp
.src(["src/js/**/*.js"])
.pipe(gulp.dest("dist/js"))
.pipe(
rename({
suffix: ".min",
})
)
.pipe(uglify())
.pipe(gulp.dest("dist/js"));
});
gulp.task("serve", function () {
// Serve files from the root of this project
browserSync.init({
server: {
baseDir: ".",
},
});
gulp.watch("src/js/**/*.js", gulp.series("js")).on("change", reload);
gulp.watch("src/scss/**/*.scss", gulp.series("scss")).on("change", reload);
gulp.watch("src/img/*", gulp.series("image")).on("change", reload);
gulp.watch("*.html").on("change", reload);
});