-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
109 lines (92 loc) · 3 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
107
108
109
var gulp = require('gulp'),
sass = require('gulp-sass'),
browserSync = require('browser-sync'),
concat = require('gulp-concat'),
uglify = require('gulp-uglifyjs'),
cssnano = require('gulp-cssnano'),
rename = require('gulp-rename'),
del = require('del'),
imagemin = require('gulp-imagemin'),
pngquant = require('imagemin-pngquant'),
cache = require('gulp-cache'),
autoprefixer = require('gulp-autoprefixer'),
postcss = require('gulp-postcss'),
mqpacker = require("css-mqpacker"),
htmlmin = require('gulp-htmlmin');
gulp.task('sassConcat', function() {
return gulp.src(['src/scss/_import.scss', 'src/blocks/**/*.scss'])
.pipe(concat('main.scss'))
.pipe(gulp.dest('src/scss/'))
});
gulp.task('sass', function() {
return gulp.src('src/scss/**/*.scss')
.pipe(sass())
.pipe(autoprefixer(['last 5 versions', '> 1%'], { cascade: true }))
.pipe(postcss([mqpacker()]))
.pipe(gulp.dest('src/css'))
.pipe(browserSync.reload({stream: true}))
});
gulp.task('browser-sync', function() {
browserSync({
server: {
baseDir: 'src'
},
notify: false
});
});
gulp.task('scripts', function() {
return gulp.src([])
.pipe(concat('libs.min.js'))
.pipe(uglify())
.pipe(gulp.dest('src/js'));
});
gulp.task('css-min', ['sass'], function() {
return gulp.src(['src/css/*.css', '!src/css/*min.css'])
.pipe(cssnano())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('src/css'));
});
gulp.task('watch', ['browser-sync', 'css-min', 'scripts'], function() {
gulp.watch('src/scss/**/*.scss', ['sass']);
gulp.watch('src/blocks/**/*.scss', ['sass']);
gulp.watch('src/*.html', browserSync.reload);
gulp.watch('src/js/**/*.js', browserSync.reload);
});
gulp.task('clean', function() {
return del.sync(['css', 'js', 'img', 'fonts', '*.html']);
});
gulp.task('img', function() {
return gulp.src('src/img/*.*')
.pipe(imagemin({
interlaced: true,
progressive: true,
svgoPlugins: [{removeViewBox: false}],
use: [pngquant()]
}))
.pipe(gulp.dest('img/'));
});
gulp.task('buildHtml', function() {
return gulp.src('src/*.html')
.pipe(gulp.dest(''))
})
gulp.task('buildCss', function() {
return gulp.src(['src/css/*.css'])
.pipe(gulp.dest('css/'))
})
gulp.task('buildFonts', function() {
return gulp.src(['src/fonts/*.*'])
.pipe(gulp.dest('fonts/'))
})
gulp.task('buildJs', function() {
return gulp.src(['src/js/*.js'])
.pipe(gulp.dest('js/'))
})
gulp.task('buildImg', function() {
return gulp.src(['src/img/*.+(jpg|png|svg)'])
.pipe(gulp.dest('img/'))
})
gulp.task('build', ['css-min', 'scripts', 'clean', 'buildImg', 'buildHtml', 'buildCss', 'buildFonts'])
gulp.task('clear', function () {
return cache.clearAll();
})
gulp.task('default', ['watch']);