forked from alibaba/ChatUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
48 lines (38 loc) · 1.02 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
const gulp = require('gulp');
const babel = require('gulp-babel');
const less = require('gulp-less');
const postcss = require('gulp-postcss');
process.env.NODE_ENV = 'production';
const paths = {
js: ['./src/**/*.js'],
dest: {
lib: 'lib',
esm: 'es',
dist: 'dist',
},
};
function fullStyle(cb) {
gulp.src('./src/styles/index.less').pipe(less()).pipe(postcss()).pipe(gulp.dest(paths.dest.dist));
cb();
}
function copyLess() {
return gulp
.src('src/**/**/*.less')
.pipe(gulp.dest(paths.dest.lib))
.pipe(gulp.dest(paths.dest.esm));
}
function compileScripts(babelEnv, destDir) {
process.env.BABEL_ENV = babelEnv;
return gulp
.src(['src/**/*.{ts,tsx}', '!src/**/__tests__/*.{ts,tsx}'])
.pipe(babel())
.pipe(gulp.dest(destDir));
}
function compileCJS() {
return compileScripts('cjs', paths.dest.lib);
}
function compileESM() {
return compileScripts('esm', paths.dest.esm);
}
exports.default = gulp.series([compileESM, compileCJS, copyLess]);
exports.umd = gulp.series([fullStyle]);