-
Notifications
You must be signed in to change notification settings - Fork 16
/
gulpfile.js
94 lines (84 loc) · 2.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
var gulp = require('gulp'),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
rename = require('gulp-rename'),
clean = require('gulp-clean'),
svgSprite = require('gulp-svg-sprite'),
gulpSequence = require('gulp-sequence');
var cssDist = 'dist/stylesheets',
svgDist = 'dist/svg-sprite'
svgCssSrc = 'src/stylesheets/icons'
imgDist = 'dist/images';
// Clean
gulp.task('clean-styles', function () {
gulp.src(cssDist, {read: false})
.pipe(clean());
});
gulp.task('clean-images', function () {
gulp.src(imgDist, {read: false})
.pipe(clean());
});
gulp.task('clean-svg-sprite', function () {
gulp.src(imgDist, {read: false})
.pipe(clean());
});
gulp.task('clean-svg-sprite-src', function () {
gulp.src(svgDist, {read: false})
.pipe(clean());
});
// Styles
gulp.task('styles', function() {
gulp.src('src/stylesheets/csmb.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest(cssDist))
.pipe(autoprefixer({
browsers: ['> 1%', 'last 4 versions'],
cascade: false
}))
.pipe(gulp.dest(cssDist))
.pipe(rename({ suffix: '-min' }))
.pipe(minifycss())
.pipe(gulp.dest(cssDist));
});
// SVG Sprite
gulp.task('svg-sprite', function() {
gulp.src('src/images/*.svg')
.pipe(svgSprite({
mode : {
css : {
dest : '.',
prefix : "%csmb-%s",
sprite : "../images/icons.svg",
dimensions : false,
bust : false,
render : {
css : true
},
example : true,
layout : 'horizontal',
common : 'csmb, .csmb-flat'
}
},
shape : {
dimension : {
precision : 5,
}
}
}))
.pipe(gulp.dest(svgDist));
});
gulp.task('move-svg-css', function() {
gulp.src(svgDist + '/sprite.css')
.pipe(rename(function (path) {
path.basename = '_sprite';
path.extname = '.scss';
}))
.pipe(gulp.dest(svgCssSrc));
});
gulp.task('move-svg-sprite', function() {
gulp.src(svgDist + '/dist/images/icons.svg')
.pipe(gulp.dest(imgDist));
});
// Default
gulp.task('default', gulpSequence('clean-svg-sprite', 'clean-images', 'svg-sprite', 'move-svg-css', 'move-svg-sprite', 'clean-svg-sprite-src', 'clean-styles', 'styles'));