-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
43 lines (41 loc) · 1.44 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
const gulp = require('gulp');
const ts = require('gulp-typescript');
const tsConfig = require('./getTSCommonConfig')();
const babelConfig = require('./getBabelCommonConfig')();
delete babelConfig.cacheDirectory;
const babel = require('gulp-babel');
const transformLess = require('atool-build/lib/transformLess');
const through2 = require('through2');
const merge2 = require('merge2');
function babelify(js) {
return js.pipe(babel(babelConfig))
.pipe(gulp.dest('lib'));
}
gulp.task('default', () => {
const less = gulp.src(['src/' + '**/' + '*.less'])
.pipe(through2.obj(function (file, encoding, next) {
this.push(file.clone());
if (file.path.match(/\/style\/index\.less$/)) {
transformLess(file.path).then((css) => {
file.contents = new Buffer(css);
file.path = file.path.replace(/\.less$/, '.css');
this.push(file);
next();
}).catch((e) => {
console.error(e);
});
} else {
next();
}
}))
.pipe(gulp.dest('lib'));
const img = gulp.src(['src/' + '**/' + '*.png']).pipe(gulp.dest('lib'));
const fonts = gulp.src(['src/**/*.eot', 'src/**/*.svg', 'src/**/*.ttf', 'src/**/*.woff']).pipe(gulp.dest('lib'));
const tsResult = gulp.src([
'src/' + '**/' + '*.tsx',
'src/' + '**/' + '*.ts',
]).pipe(ts(tsConfig));
const tsFiles = babelify(tsResult.js);
const tsd = tsResult.dts.pipe(gulp.dest('lib'));
return merge2([tsFiles, tsd]);
});