-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
81 lines (74 loc) · 2.04 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
// dependency
var colors = require("colors/safe");
// var util = require("./util");
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 es3ify = require("gulp-es3ify");
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_lib", function(cb) {
console.log(colors.info("###### pack_lib start ######"));
gulp
.src([
path.join(process.cwd(), "./js/**/*.js"),
path.join(process.cwd(), "./js/**/*.jsx")
])
.pipe(
babel({
presets: ["react", "es2015-ie", "stage-1"].map(function(item) {
return require.resolve("babel-preset-" + item);
}),
plugins: [
"transform-object-assign",
"add-module-exports",
"transform-object-entries",
"transform-object-rest-spread"
].map(function(item) {
return require.resolve("babel-plugin-" + item);
})
})
)
.pipe(es3ify())
.pipe(gulp.dest("lib/"))
.on("end", function() {
console.log(colors.info("###### pack_lib done ######"));
cb();
});
});
// gulp.task("sass_component", function() {
// gulp
// .src([path.join(process.cwd(), "./src/**/*.scss")])
// .pipe(sass())
// .pipe(gulp.dest("./lib"));
// console.log("###### sass_component done ######");
// });
// gulp.task("css_component", function() {
// gulp
// .src([path.join(process.cwd(), "./css/*.css")])
// .pipe(gulp.dest("./lib/css"));
// console.log("###### css_component done ######");
// });
gulp.task("clean_lib", function() {
return shelljs.rm("-rf", getFromCwd("lib"));
});
gulp.task("lib", ["clean_lib","pack_lib"], function() {});
gulp.task('default',['lib']);