-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
62 lines (52 loc) · 1.53 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
const path = require("path");
const gulp = require("gulp");
const sass = require("gulp-sass");
const rename = require("gulp-rename");
const changed = require("gulp-changed");
/*******************
* 全局配置
*******************/
var config = {
pages: path.resolve(__dirname, "pages"),
components: path.resolve(__dirname, "components"),
assets: path.resolve(__dirname, "assets"),
templates: path.resolve(__dirname,"templates")
};
/*******************
* 任务
*******************/
// pages目录下sass 处理
gulp.task('pageScss', function () {
return gulp.src(config.pages + '/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(rename(function(path){
path.extname = '.wxss';
}))
.pipe(gulp.dest(config.pages))
.on('end', function() {
console.log('[完成] sass 编译完毕');
});
});
// components目录下sass 处理
gulp.task('componentScss', function () {
return gulp.src(config.components + '/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(rename(function(path){
path.extname = '.wxss';
}))
.pipe(gulp.dest(config.components))
.on('end', function() {
console.log('[完成] sass 编译完毕');
});
});
//监视
gulp.task('watch', function(event) {
gulp.watch('./pages/**/*.scss', ['pageScss']);
gulp.watch('./components/**/*.scss', ['componentScss']);
gulp.watch('./assets/**/*.scss', ['pageScss']);
gulp.watch('./templates/**/*.scss', ['pageScss']);
});
//开发
gulp.task('dev', ['pageScss','componentScss','watch']);
//默认任务
gulp.task('default', ['dev']);