-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
85 lines (72 loc) · 2.2 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
const
gulp = require('gulp'),
sass = require('gulp-sass'),
browserSync = require("browser-sync").create(),
del = require('del'),
cache = require('gulp-cache'),
autoPrefixer = require('gulp-autoprefixer'),
imagemin = require('gulp-imagemin'),
uglify = require('gulp-uglify-es').default,
concatCss = require('gulp-concat-css'),
cleanCSS = require('gulp-clean-css'),
rename = require("gulp-rename");
function gulpSass() {
return gulp
.src('./src/assets/scss/**/*.scss')
.pipe(sass({ outputStyle: "compressed" }))
.pipe(autoPrefixer({
browsers: ['last 4 versions'],
cascade: false
}))
.pipe(gulp.dest('src/assets/css'))
.pipe(browserSync.stream());
}
function minCss() {
return gulp.src(['src/assets/css/bootstrap-grid.min.css','src/assets/css/swiper.css', 'src/assets/css/style.css'])
.pipe(concatCss("style.min.css"))
.pipe(cleanCSS())
.pipe(gulp.dest('dist/assets/css/'));
};
function gulpImgMin() {
return gulp.src('./src/assets/img/**/*')
.pipe(imagemin({
progressive: true,
optimizationLevel: 3,
quality: 50
}))
.pipe(gulp.dest('./dist/assets/img/'))
}
function gulpUglify() {
return gulp
.src('src/assets/js/script.js')
.pipe(rename("script.min.js"))
.pipe(uglify())
.pipe(gulp.dest('dist/assets/js/'))
}
function startServer(done) {
browserSync.init({
proxy: "diploma"
});
done();
}
function clean() {
return del(["dist"]);
}
function clear() {
return cache.clearAll();
}
function reload(done) {
browserSync.reload();
done();
}
function watchFiles(done) {
gulp.watch('./src/assets/scss/**/*.scss', gulp.parallel(gulpSass,reload));
gulp.watch('./src/assets/css/**/style.css', gulp.parallel(minCss,reload));
gulp.watch("./src/**/*.php", gulp.parallel(reload));
gulp.watch('./src/assets/js/script.js', gulp.parallel(gulpUglify,reload));
done();
}
gulp.task('default',gulp.parallel(watchFiles, startServer));
gulp.task('minImg',gulp.parallel(gulpImgMin));
exports.clean = clean;
exports.clear = clear;