-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
59 lines (50 loc) · 1.5 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
var gulp = require("gulp"),
sass = require("gulp-sass"),
sprite = require("gulp.spritesmith"),
sourcemaps = require("gulp-sourcemaps");
var nodemon = require("gulp-nodemon");
// 监听 app.js mock/*, 自动重启服务
gulp.task('serve-dev', function() {
var options = {
script: 'app.js',
execMap: {
"js": "node --harmony"
},
ext: "js json",
env: {
/*'PORT': port,*/
'NODE_ENV': 'development'
},
watch: ['app.js', 'mock/*']
};
nodemon(options).on('restart', function(files) {
// when reload , livereload the broswer
console.log('App restarted due to: ', files);
});
});
// 编译 sass
gulp.task('sass', function() {
gulp.src('static/sass/**/*.scss')
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(sourcemaps.write('./maps'))
.pipe(gulp.dest('static/css'));
gulp.watch('static/sass/**/*.scss', ['sass']);
});
gulp.task('sass:watch', function() {
// gulp.watch('static/sass/**/*.scss', ['sass']);
});
// 合成雪碧图
gulp.task('sprite', function() {
var spriteData = gulp.src('static/img/common/*.png')
.pipe(sprite({
imgName: 'sprite-common.png',
cssName: 'sprite-common.css',
padding: 10
}));
spriteData.img.pipe(gulp.dest('static/img/common'));
spriteData.css.pipe(gulp.dest('static/css/common'));
});
gulp.task('default', function() {
gulp.run('serve-dev', 'sass');
});