-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
50 lines (47 loc) · 1.22 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
const path = require('path');
const gulp = require('gulp');
const through2 = require('through2');
const ts = require('gulp-typescript');
const sourcemaps = require('gulp-sourcemaps');
const merge = require('merge-stream');
const tsConfig = {
allowJs: true,
alwaysStrict: true,
declaration: true,
esModuleInterop: true,
forceConsistentCasingInFileNames: true,
jsx: 'react',
lib: ['dom', 'es2017'],
moduleResolution: 'node',
noFallthroughCasesInSwitch: true,
noImplicitAny: true,
noUnusedLocals: true,
noUnusedParameters: true,
resolveJsonModule: true,
skipLibCheck: true,
strict: true,
target: 'es5',
downlevelIteration: true,
};
const tsFiles = ['src/**/*.{ts,tsx}'];
gulp.task('compile', function() {
const tsResult = gulp
.src(tsFiles, {
base: path.join(process.cwd(), 'src'),
})
.pipe(sourcemaps.init())
.pipe(ts(tsConfig));
return merge(
tsResult,
tsResult.js.pipe(
through2.obj(function(file, encoding, next) {
console.log(file.path, file.base);
file.path = file.path.replace(/\.[jt]sx$/, '.js');
this.push(file);
next();
})
)
)
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(path.join(process.cwd(), 'lib')));
});