forked from kubesphere/kube-design
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
57 lines (45 loc) · 1.21 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
const gulp = require("gulp");
const babel = require("gulp-babel");
const sass = require("gulp-sass");
const autoprefixer = require("gulp-autoprefixer");
sass.compiler = require("node-sass");
const paths = {
dest: {
lib: "lib",
esm: "esm",
dist: "dist",
},
styles: ["src/**/**/*.scss"],
scripts: ["src/**/**/*.{js,jsx}", "!src/**/**/*.test.js"],
};
function compileScripts(babelEnv, destDir) {
const { scripts } = paths;
process.env.BABEL_ENV = babelEnv;
return gulp.src(scripts).pipe(babel()).pipe(gulp.dest(destDir));
}
function compileCJS() {
const { dest } = paths;
return compileScripts("cjs", dest.lib);
}
function compileESM() {
const { dest } = paths;
return compileScripts("esm", dest.esm);
}
function buildStyles() {
return gulp
.src(paths.styles)
.pipe(sass())
.pipe(autoprefixer())
.pipe(gulp.dest(paths.dest.lib))
.pipe(gulp.dest(paths.dest.esm));
}
function copyStyles() {
return gulp
.src(paths.styles)
.pipe(gulp.dest(paths.dest.lib))
.pipe(gulp.dest(paths.dest.esm));
}
const buildScripts = gulp.series(compileCJS, compileESM);
const build = gulp.parallel(buildScripts, copyStyles, buildStyles);
exports.build = build;
exports.default = build;