-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
94 lines (86 loc) · 2.4 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// dependency
var colors = require("colors/safe");
var path = require("path");
var shelljs = require("shelljs");
// gulp & gulp plugin
var gulp = require("gulp");
var babel = require("gulp-babel");
var sass = require("gulp-sass");
// var less = require("gulp-less");
var es3ify = require("gulp-es3ify");
var concat = require("gulp-concat")
// var cleancss = require("gulp-clean-css");
var cssUglify = require('gulp-minify-css');
colors.setTheme({
silly: 'rainbow',
input: 'grey',
verbose: 'cyan',
prompt: 'grey',
info: 'green',
data: 'grey',
help: 'cyan',
warn: 'yellow',
debug: 'blue',
error: 'red'
});
var getFromCwd = function() {
var args = [].slice.call(arguments, 0);
args.unshift(process.cwd());
return path.join.apply(path, args);
};
gulp.task("pack_lib2", function(cb) {
console.log(colors.info("###### pack_lib2 start ######"));
gulp
.src([
path.join(process.cwd(), "./src/**/*.js"),
// path.join(process.cwd(), "./js/**/*.jsx")
])
.pipe(
babel()
)
.pipe(es3ify())
.pipe(gulp.dest("lib/"))
.on("end", function() {
console.log(colors.info("###### pack_lib2 done ######"));
cb();
});
});
gulp.task("move_style", function() {
gulp
.src([
// path.join(process.cwd(), "./src/theme-red.css"),
path.join(process.cwd(), "./src/**/*.less"),
path.join(process.cwd(), "./src/theme-red.scss"),
path.join(process.cwd(), "./src/index.scss"),
])
.pipe(gulp.dest("./lib"));
console.log("###### move_style done ######");
});
gulp.task("less_component",["move_style"], function() {
gulp
.src([
path.join(process.cwd(), "./src/index.scss"),
])
.pipe(sass())
.pipe(cssUglify())
.pipe(gulp.dest("./lib"));
console.log("###### less_component done ######");
});
//将lib下的index.css合并dist下的index.css生成完成的index.css
gulp.task("change_dist",["less_component"], function() {
gulp.src([
path.join(process.cwd(), "./src/index.scss"),
path.join(process.cwd(), "./dist/index.css"),
])
.pipe(sass())
.pipe(concat('./dist/index.css'))
.pipe(cssUglify())
.pipe(gulp.dest("./"));
console.log("###### change_dist done ######");
});
gulp.task("clean_lib2", function() {
return shelljs.rm("-rf", getFromCwd("lib"));
});
gulp.task("lib2", ["clean_lib2","pack_lib2"], function() {});
gulp.task('default',['lib2', 'change_dist']);
// gulp.task('default',['theme_src']);