-
Notifications
You must be signed in to change notification settings - Fork 17
/
gulpfile.js
69 lines (51 loc) · 1.98 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
var gulp = require('gulp');
var autoprefixer = require('gulp-autoprefixer');
var minifyCss = require('gulp-minify-css');
var replace = require('gulp-replace');
var rename = require('gulp-rename');
var sass = require('gulp-sass');
var spritesmith = require('gulp.spritesmith');
var sassDir = './sass/**/*.scss';
gulp.task('sprites', function() {
var spriteData = gulp.src('images/Icons/*.png').pipe(spritesmith({
imgName: 'spritesheet.png',
cssName: '_sprites.scss',
algorithm: 'binary-tree',
cssVarMap: function (sprite) {
sprite.name = 'icon-' + sprite.name;
}
}));
spriteData.img.pipe(gulp.dest('./images/')); // output path for the sprite
spriteData.css
.pipe(replace('spritesheet.png', '%%spritesheet%%'))
.pipe(gulp.dest('./sass/')); // output path for the CSS
});
gulp.task('build', function() {
// return gulp.src('./slique.css')
return gulp.src(sassDir)
.pipe(sass().on('error', sass.logError))
/* Uncomment reddit resources, e.g. background: url(%%image%%); */
.pipe(replace(/\/\*(?:(?:.|\n)(?:(?!\*\/)))*?(.*%%.*;)(?:.|\n)*?\*\//g,'$1'))
/* Remove normal urls with external resources */
.pipe(replace(/\n.*?url\([\'\"]?[^%].*/g,''))
.pipe(replace('@charset "UTF-8";',''))
.pipe(autoprefixer())
/* Remove not allowed webkit flex prefixes from autoprefixer */
// .pipe(replace(/.*-webkit-box(-(align|orient|ordinal|direction))?.*/g,''))
.pipe(replace(/.*-webkit-box.*;/g,''))
.pipe(minifyCss())
// .pipe(rename('./slique.css'))
.pipe(gulp.dest('./'));
});
gulp.task('sass', function() {
return gulp.src(sassDir)
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./stylesheets/'));
});
gulp.task('watch', function() {
gulp.watch(sassDir, ['sass']);
});
gulp.task('watch-build', function() {
gulp.watch(sassDir, ['sass', 'build']);
});
gulp.task('default', ['build']);