-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
120 lines (108 loc) · 3.01 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
110
111
112
113
114
115
116
117
118
119
120
const { src, dest, watch, parallel, series } = require('gulp');
const scss = require('gulp-sass');
const concat = require('gulp-concat');
const autoprefixer = require('gulp-autoprefixer');
const uglify = require('gulp-uglify');
const imagemin = require('gulp-imagemin');
const svgSprite = require('gulp-svg-sprite');
const fileinclude = require('gulp-file-include');
const del = require('del');
const browserSync = require('browser-sync').create();
function browsersync() {
browserSync.init({
server: {
baseDir: 'app/'
},
notify: false
})
}
function fileInclude() {
return src('app/html/**/*.html')
.pipe(fileinclude({
prefix: '@@',
basepath: '@file'
}))
.pipe(dest('app/'))
.pipe(browserSync.stream())
}
function styles() {
return src('app/scss/style.scss')
.pipe(scss({outputStyle: 'compressed'}))
.pipe(concat('style.min.css'))
.pipe(autoprefixer({
overrideBrowserslist: ['last 10 versions'],
grid: true
}))
.pipe(dest('app/css'))
.pipe(browserSync.stream())
}
function scripts() {
return src([
'node_modules/jquery/dist/jquery.js',
'node_modules/slick-carousel/slick/slick.js',
'node_modules/mixitup/dist/mixitup.js',
'node_modules/@fancyapps/fancybox/dist/jquery.fancybox.js',
'node_modules/ion-rangeslider/js/ion.rangeSlider.js',
'node_modules/rateyo/src/jquery.rateyo.js',
'node_modules/jquery-form-styler/dist/jquery.formstyler.js',
'app/js/main.js'
])
.pipe(concat('main.min.js'))
.pipe(uglify())
.pipe(dest('app/js'))
.pipe(browserSync.stream())
}
function images() {
return src('app/images/**/*.*')
.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/images'))
}
function svgSprites() {
return src('app/images/**/*.svg')
.pipe(svgSprite({
mode: {
stack: {
sprite: "../sprite.svg"
}
}
}))
.pipe(dest('app/sprite/'))
}
function cleanDist(){
return del('dist')
}
function build(){
return src([
'app/*.html',
'app/css/style.min.css',
'app/js/main.min.js'
], {base: 'app'})
.pipe(dest('dist'))
}
function watching() {
watch(['app/html/*.html'], fileInclude);
watch(['app/scss/**/*.scss'], styles);
watch(['app/js/**/*.js', '!app/js/main.min.js'], scripts);
watch(['app/images/**.svg'], svgSprites);
watch(['app/**/*.html']).on('change', browserSync.reload);
}
exports.fileInclude = fileInclude;
exports.styles = styles;
exports.scripts = scripts;
exports.browsersync = browsersync;
exports.watching = watching;
exports.images = images;
exports.svgSprites = svgSprites;
exports.cleanDist = cleanDist;
exports.build = series(cleanDist, images, build);
exports.default = parallel(fileInclude, styles, scripts, svgSprites, browsersync, watching);