|
1 | 1 | const gulp = require('gulp');
|
| 2 | +const shell = require('gulp-shell'); |
| 3 | +const sequence = require('gulp-sequence'); |
2 | 4 |
|
3 | 5 | gulp.task('clean', () => {
|
4 | 6 | const del = require('del');
|
5 | 7 | return del('./dist/');
|
6 | 8 | });
|
7 | 9 |
|
8 |
| -gulp.task('compile-ts', () => { |
9 |
| - const ts = require('gulp-typescript'); |
10 |
| - const tsProject = ts.createProject('./tsconfig.json'); |
11 |
| - const dest = tsProject.options.outDir; |
12 |
| - return tsProject.src() |
13 |
| - .pipe(tsProject()) |
14 |
| - .pipe(gulp.dest(dest)); |
15 |
| -}); |
| 10 | +gulp.task('compile-ts', shell.task('tsc -m commonjs')); |
16 | 11 |
|
17 |
| -gulp.task('compile-ts-umd', () => { |
18 |
| - const ts = require('gulp-typescript'); |
19 |
| - const tsProject = ts.createProject('./tsconfig.json'); |
20 |
| - const path = require('path'); |
21 |
| - const dest = path.join(tsProject.options.outDir, 'umd'); |
22 |
| - tsProject.options.module = 3; |
23 |
| - return tsProject.src() |
24 |
| - .pipe(tsProject()) |
25 |
| - .pipe(gulp.dest(dest)); |
26 |
| -}); |
| 12 | +gulp.task('compile-ts-umd', shell.task('tsc -t es5 -m umd --outDir ./dist/umd/')); |
27 | 13 |
|
28 |
| -gulp.task('watch-ts', async () => { |
29 |
| - const ts = require('gulp-typescript'); |
30 |
| - const tsProject = ts.createProject('./tsconfig.json'); |
31 |
| - const path = require('path'); |
32 |
| - const dest = tsProject.options.outDir; |
33 |
| - await tsProject.src() |
34 |
| - .pipe(tsProject()) |
35 |
| - .pipe(gulp.dest(dest)); |
36 |
| - return gulp.watch(['./src/**/*.ts'], (file) => { |
37 |
| - const tsProject = ts.createProject('./tsconfig.json'); |
38 |
| - const relative = path.relative('./', path.dirname(file.path)); |
39 |
| - const outDir = tsProject.options.outDir; |
40 |
| - const dest = path.join(outDir, relative); |
41 |
| - return gulp.src(file.path) |
42 |
| - .pipe(tsProject()) |
43 |
| - .pipe(gulp.dest(dest)); |
44 |
| - }); |
45 |
| -}); |
| 14 | +gulp.task('watch-ts', shell.task('tsc -w -t es5 -m umd --outDir ./dist/umd/')); |
46 | 15 |
|
47 |
| -gulp.task('default', (cb) => { |
48 |
| - const sequence = require('gulp-sequence'); |
49 |
| - sequence('clean', 'compile-ts', 'compile-ts-umd', cb); |
50 |
| -}); |
| 16 | +gulp.task('default', sequence('clean', 'compile-ts', 'compile-ts-umd')); |
51 | 17 |
|
52 | 18 | gulp.task('dev', ['watch-ts']);
|
0 commit comments