-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
98 lines (84 loc) · 2.89 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
const { src, dest, watch, parallel, series } = require("gulp");
const scss = require("gulp-sass"); // минификация
const concat = require("gulp-concat"); // конкатенация/объединение + имя
const browserSync = require("browser-sync").create(); // live update
const uglify = require("gulp-uglify-es").default;
const autoprefixer = require("gulp-autoprefixer");
const imagemin = require("gulp-imagemin"); // отпимизация img
const del = require("del"); // удаление dist-папки
const ghpages = require('gh-pages'); // gh-pages for dist folder
ghpages.publish('dist', { //npm run deploy
repo: 'https://github.com/Fpsska/virtual-piano.git',
message: 'Auto-generated commit'
});
function browsersync() { // live update
browserSync.init({
server: {
baseDir: "app/"
}
});
}
function images() {
return src("app/assets/img/**/*")
.pipe(imagemin([
imagemin.gifsicle({ interlaced: true }),
imagemin.mozjpeg({ quality: 75, progressive: true }),
imagemin.optipng({ optimizationLevel: 5 }),
imagemin.svgo({
plugins: [
{ removeViewBox: true },
{ cleanupIDs: false }
]
})
]
))
.pipe(dest("dist/assets/img"));
}
function scripts() {
return src([
"node_modules/jquery/dist/jquery.js",
"app/assets/js/main.js"
])
.pipe(concat("main.min.js")) // конкатенация + единое название
// .pipe(uglify()) // минификация
.pipe(dest("app/assets/js")) // конечный путь
.pipe(browserSync.stream());
}
function styles() { /*КОМПИЛЯЦИЯ scss -> style.min.css*/
return src("app/assets/scss/style.scss")
.pipe(scss({ outputStyle: "expanded" }))
.pipe(concat("style.min.css"))
.pipe(dest("app/css"));
}
function audio() {
return src("app/assets/audio/**/*.mp3")
.pipe(dest("app/assets/audio"));
}
function watching() {
watch(["app/assets/scss/**/*.scss"], styles);
watch(["app/assets/js/**/*.js", "!app/assets/js/main.min.js"], scripts);
watch(["app/assets/audio/**/*.mp3"], audio);
watch(["app/*.html"]).on("change", browserSync.reload);
}
function build() {
return src([
"app/*.html",
"app/css/style.min.css",
"app/assets/js/main.min.js",
"app/assets/audio/**/*.mp3"
], { base: "app" })
.pipe(dest([
"dist"
]));
}
function cleanDist() {
return del("dist");
}
exports.styles = styles;
exports.watching = watching;
exports.browsersync = browsersync;
exports.scripts = scripts;
exports.images = images;
exports.cleanDist = cleanDist;
exports.build = series(cleanDist, images, build);
exports.default = parallel(styles, scripts, audio, browsersync, watching);