-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathgulpfile.js
75 lines (62 loc) · 1.58 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
const gulp = require("gulp");
const babel = require("gulp-babel");
const clean = require("del");
const ts = require("gulp-typescript");
const merge = require("merge2");
const tsProject = ts.createProject("./tsconfig.json");
const ESDIR = "./es";
const LIBDIR = "./lib";
const PACKAGE_DIR = "packages/**/*.js";
/* eslint-disable */
gulp.task("clean", () => {
return clean(["lib"]);
});
/* eslint-disable */
gulp.task("cleanEs", () => {
return clean(["es"]);
});
function moveLess(dir) {
return gulp.src("./packages/**/*.less").pipe(gulp.dest(dir));
}
function compileTs() {
return tsProject.src().pipe(tsProject());
}
function babelConfig(moduleType) {
return {
babelrc: false,
presets: [
["@babel/preset-env", { modules: moduleType }],
"@babel/preset-react"
],
plugins: [
"@babel/plugin-proposal-object-rest-spread",
["@babel/plugin-proposal-decorators", { legacy: true }],
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-classes"
]
};
}
gulp.task(
"es",
gulp.series("cleanEs", () => {
const jsStream = gulp
.src(PACKAGE_DIR)
.pipe(babel(false))
.pipe(gulp.dest(ESDIR));
const cssStream = moveLess(ESDIR); // 处理css流
return merge(jsStream, cssStream);
})
);
// 发布打包
gulp.task(
"lib",
gulp.series("clean", () => {
const jsStream = gulp
.src(PACKAGE_DIR)
.pipe(babel())
.pipe(gulp.dest(LIBDIR));
const cssStream = moveLess(LIBDIR); // 处理css流
return merge(jsStream, cssStream);
})
);
gulp.task("default", gulp.series("lib", "es"));