-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
38 lines (32 loc) · 1.03 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
var gulp = require('gulp');
var sass = require('gulp-ruby-sass');
var spriter = require('gulp-css-spriter');
gulp.task('sass', function () {
return sass('public/css/', { 'style': 'expanded' })
.on('error', function (err) {
console.error('Error!', err.message);
})
.pipe(gulp.dest('public/css/'));
});
gulp.task('watch', function(){
gulp.watch('public/css/mobile/*.scss', ['sass']);
});
/**
* 图片合并
* 雪碧图
*
*/
gulp.task('spr', function() {
var timestamp = +new Date();
//需要自动合并雪碧图的样式文件
return gulp.src('public/css/style.css')
.pipe(spriter({
// 生成的spriter图片的位置
'spriteSheet': 'public/images/bgs_' + timestamp + '.png',
// CSS里生成样式文件图片引用地址的路径
// 如下将生产:backgound:url(../images/sprite20324232.png)
'pathToSpriteSheetFromCSS': '../images/bgs_' + timestamp + '.png'
}))
//产出路径
.pipe(gulp.dest('public/css/'));
});