-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
118 lines (101 loc) · 3.39 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
var gulp = require('gulp'),
sass = require('gulp-sass'),
concatCss = require('gulp-concat-css'),
rename = require('gulp-rename'),
cssNano = require('gulp-cssnano'),
browserSync = require('browser-sync'),
concatJs = require('gulp-concat'),
uglify = require('gulp-uglifyjs'),
del = require('del'),
imagemin = require('gulp-imagemin'),
pngquant = require('imagemin-pngquant'),
cache = require('gulp-cache'),
autoprefixer = require('gulp-autoprefixer'),
gcmq = require('gulp-group-css-media-queries'),
svgSprite = require('gulp-svg-sprite'),
svgmin = require('gulp-svgmin'),
cheerio = require('gulp-cheerio'),
replace = require('gulp-replace');
gulp.task('sass', function () {
return gulp.src('app/scss/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer(['last 15 versions'], {cascade: true}))
.pipe(gcmq())
.pipe(gulp.dest('app/css'))
.pipe(browserSync.reload({stream: true}));
});
gulp.task('browser-sync', function () {
browserSync({
server: {
baseDir: "./app/"
},
notify: true
});
});
gulp.task('clean', function () {
return del.sync('dist');
});
gulp.task('clear', function () {
return cache.clearAll();
});
gulp.task('plugin-css', function() {
return gulp.src('app/scss//_smartBasket.scss')
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer(['last 15 versions'], {cascade: true}))
.pipe(gcmq())
.pipe(gulp.dest('app/css'))
});
gulp.task('watch', ['browser-sync', 'sass', 'plugin-css'], function () {
gulp.watch('app/scss/**/*.scss', ['sass']);
gulp.watch('app/*.html', browserSync.reload);
gulp.watch('app/js/*.js', browserSync.reload);
});
gulp.task('img', function () {
return gulp.src('app/img/**/*')
.pipe(gulp.dest('dist/img'));
});
gulp.task('build', ['img', 'clean', 'sass'], function () {
var buildCss = gulp.src('app/css/**/*.css')
.pipe(gulp.dest('dist/css'));
var buildJs = gulp.src('app/js/**/*.js')
.pipe(gulp.dest('dist/js'));
var buildFonts = gulp.src('app/fonts/**/*')
.pipe(gulp.dest('dist/fonts'));
var buildHtml = gulp.src('app/*.html')
.pipe(gulp.dest('dist'));
});
gulp.task('svgSpriteBuild', function () {
return gulp.src('./app/img/icons/*.svg')
// minify svg
.pipe(svgmin({
js2svg: {
pretty: true
}
}))
// remove all fill, style and stroke declarations in out shapes
.pipe(cheerio({
run: function ($) {
$('[fill]').removeAttr('fill');
$('[stroke]').removeAttr('stroke');
$('[style]').removeAttr('style');
},
parserOptions: {xmlMode: true}
}))
// cheerio plugin create unnecessary string '>', so replace it.
.pipe(replace('>', '>'))
// build svg sprite
.pipe(svgSprite({
mode: {
symbol: {
sprite: "../sprite.svg",
render: {
scss: {
dest:'../../../scss/helpers/_sprite.scss',
template: "./app/scss/helpers/_sprite_template.scss"
}
}
}
}
}))
.pipe(gulp.dest('./app/img/sprite/'));
});