-
Notifications
You must be signed in to change notification settings - Fork 29
/
gulpfile.js
43 lines (31 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
var gulp = require('gulp'),
ts = require('gulp-typescript'),
tsProject = ts.createProject('tsconfig.json'),
sourcemaps = require('gulp-sourcemaps');
gulp.task('ts-scripts', [ 'ts-scripts-es6', 'ts-scripts-commonjs' ]);
gulp.task('ts-scripts-es6', function() {
var tsConfig = tsProject.config.compilerOptions;
tsConfig.module = 'es6'; // force module type = 'es6'
var tsResult = gulp.src("./src/**/*.ts")
.pipe(sourcemaps.init({largeFile: true, loadMaps: true}))
.pipe(ts(tsConfig));
return tsResult.js
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist/es6'));
});
gulp.task('ts-scripts-commonjs', function() {
var tsConfig = tsProject.config.compilerOptions;
tsConfig.module = 'commonjs'; // force module type = 'commonjs'
var tsResult = gulp.src("./src/**/*.ts")
.pipe(sourcemaps.init({largeFile: true, loadMaps: true}))
.pipe(ts(tsConfig));
return tsResult.js
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist/commonjs'));
});
gulp.task('watch', [ 'ts-scripts' ], function() {
gulp.watch('./src/*.ts', [ 'ts-scripts' ]);
});
gulp.task('default', [ 'ts-scripts' ], function() {
// Production-ready build
});