-
Notifications
You must be signed in to change notification settings - Fork 0
/
sass-support.js
51 lines (45 loc) · 1.59 KB
/
sass-support.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
// styles task override for Sass
module.exports = function (pho) {
var gulp = require('gulp');
var path = require('path');
var gulpSass = require('gulp-sass');
var $ = pho.$;
var cache = pho.cache;
var config = pho.config;
var sassConfig = {
/* SASS style file compilation */
enabled: true,
errLogToConsole: false,
includePaths: [ // directories for locating Sass files
'src/styles/',
'src/bower_components/',
].concat(require('node-neat').includePaths, require('node-bourbon').includePaths),
outputStyle: 'compressed'
};
gulp.task('styles', function(cb) {
if (cache.isClean('styles')) { return cb(); }
cache.setClean('styles');
var spriteFilter = $.filter('**/*.png');
var cssFilter = $.filter('**/*.css');
gulp.src(path.join(config.dist.styleDir, config.dist.styleFiles), { read: false })
.pipe($.clean())
.on('end', function() {
gulp.src(path.join(config.src.styleDir, config.src.styleMain))
.pipe($.plumber(config.plumber))
.pipe(gulpSass(sassConfig))
.on('error', function () {
// continous error reporting hack
cb(null);
})
.pipe($.base64(config.base64))
.pipe($.spritesPreprocessor(config.spritesPreprocessor))
.pipe(spriteFilter)
.pipe(gulp.dest(config.dist.spriteDir))
.pipe(spriteFilter.restore())
.pipe(cssFilter)
.pipe($.rename({ suffix: '-' + Date.now().toString() }))
.pipe(gulp.dest(config.dist.styleDir))
.on('end', cb);
});
});
};