-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
106 lines (91 loc) · 2.55 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
const del = require("del");
const gulp = require("gulp");
const scss = require("gulp-sass");
const cache = require("gulp-cache");
const imagemin = require("gulp-imagemin");
const browserSync = require("browser-sync");
const pngquant = require("imagemin-pngquant");
const concat = require("gulp-concat");
const rename = require("gulp-rename");
const uglify = require("gulp-uglifyjs");
const cssnano = require("gulp-cssnano");
const autoprefixer = require("gulp-autoprefixer");
gulp.task("sass", () =>
gulp
.src("**/scss/**/*.scss")
.pipe(scss({ outputStyle: "compressed" }))
.pipe(
autoprefixer(["last 15 versions", "> 1%", "ie 8", "ie 7", "ie 6"], {
cascade: true,
})
)
.pipe(gulp.dest("app/css"))
.pipe(browserSync.reload({ stream: true }))
);
gulp.task("browser-sync", () => {
browserSync({
server: {
baseDir: "app",
},
notify: false,
});
});
gulp.task("scripts", () =>
gulp
.src(["app/libs/jquery/dist/jquery.min.js"])
.pipe(concat("libs.min.js"))
.pipe(uglify())
.pipe(gulp.dest("app/js"))
);
gulp.task(
"css-libs",
gulp.parallel("sass", () =>
gulp
.src("**/css/libs.css", { allowEmpty: true })
.pipe(cssnano())
.pipe(rename({ suffix: ".min" }))
.pipe(gulp.dest("app/css"))
)
);
gulp.task("html", () =>
gulp.src("app/*.html").pipe(browserSync.reload({ stream: true }))
);
gulp.task("javascript", () =>
gulp.src("app/js/**/*.js").pipe(browserSync.reload({ stream: true }))
);
gulp.task(
"watch",
gulp.parallel("browser-sync", "css-libs", "scripts", () => {
gulp.watch("app/scss/**/*.scss", gulp.parallel("sass"));
gulp.watch("app/*.html", gulp.parallel("html"));
gulp.watch("app/js/**/*.js", gulp.parallel("javascript"));;
})
);
gulp.task("clean", () => del.sync("dist"));
gulp.task("img", () => {
gulp
.src("app/img/**/*")
.pipe(
cache(
imagemin({
interlaced: true,
progressive: true,
svgoPlugins: [{ removeViewBox: false }],
use: [pngquant()],
})
)
)
.pipe(gulp.dest("dist/img"));
});
gulp.task(
"build",
gulp.parallel("clean", "img", "sass", "scripts", () => {
const buildCss = gulp
.src(["app/css/main.css", "app/css/libs.min.css"])
.pipe(gulp.dest("dist/css"));
const buildFonts = gulp.src("app/fonts/**/*").pipe(gulp.dest("dist/fonts"));
const buildJs = gulp.src("app/js/**/*").pipe(gulp.dest("dist/js"));
const buildHtml = gulp.src("app/*.html").pipe(gulp.dest("dist"));
})
);
gulp.task("clear", (callback) => cache.clearAll());