forked from OPU-FE-TEAM/opu-components-vue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
101 lines (94 loc) · 2.28 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
94
95
96
97
98
99
100
101
const gulp = require("gulp");
const babel = require("gulp-babel");
const uglify = require("gulp-uglify");
const rename = require("gulp-rename");
const replace = require("gulp-replace");
const clean = require("gulp-clean");
const sass = require("gulp-sass");
const cleanCSS = require("gulp-clean-css");
const prefixer = require("gulp-autoprefixer");
const components = ["dataForm", "dataTable"];
gulp.task("build_modules", () => {
return gulp
.src("packages/**/*.js")
.pipe(
babel({
presets: ["@babel/env"]
})
)
.pipe(gulp.dest("lib"))
.pipe(uglify())
.pipe(
rename({
suffix: ".min",
extname: ".js"
})
)
.pipe(gulp.dest("lib"));
});
gulp.task("copy_ts", () => {
return gulp.src("packages/**/*.d.ts").pipe(gulp.dest("lib"));
});
gulp.task("lib_rename", () => {
return Promise.all([
gulp
.src("lib/opu.umd.js")
.pipe(
rename({
basename: "index",
extname: ".js"
})
)
.pipe(gulp.dest("lib")),
gulp
.src("lib/opu.umd.min.js")
.pipe(
rename({
basename: "index",
suffix: ".min",
extname: ".js"
})
)
.pipe(gulp.dest("lib"))
]);
});
gulp.task(
"build_style",
gulp.series("build_modules", "copy_ts", () => {
return Promise.all(
components.map(name => {
Promise.all([
gulp.src("styles/index.js").pipe(gulp.dest(`lib/${name}/style`)),
gulp
.src(`styles/${name}.scss`)
.pipe(
replace(/(\/\*\*Variable\*\*\/)/, `@import './variable.scss';\n`)
)
.pipe(sass())
.pipe(
prefixer({
borwsers: ["last 1 version", "> 1%", "not ie <= 8"],
cascade: true,
remove: true
})
)
.pipe(cleanCSS())
.pipe(
rename({
basename: "style",
extname: ".css"
})
)
.pipe(gulp.dest(`lib/${name}/style`))
]);
})
);
})
);
gulp.task(
"build_clean",
gulp.series("build_style", "lib_rename", () => {
return gulp.src(["lib/demo.html"]).pipe(clean());
})
);
gulp.task("build", gulp.parallel("build_clean"));