forked from jfoliveira/laravel-elixir-typescript
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
32 lines (27 loc) · 1004 Bytes
/
index.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
var gulp = require('gulp');
var elixir = require('laravel-elixir');
var ts = require('gulp-typescript');
var concat = require('gulp-concat');
var _ = require('underscore');
var Task = elixir.Task;
elixir.extend('typescript', function (output, dest, options) {
var pluginName = 'typescript';
var search = '**/*.+(ts)';
var assetPath = './' + elixir.config.assetsPath;
options = _.extend({
sortOutput: true
}, options);
new Task(pluginName, function () {
var tsResult = gulp.src(assetPath + '/**/*.ts')
.pipe(ts(options))
.on('error', function(e) {
new elixir.Notification().error(e, 'TypeScript Compilation Failed!');
this.emit('end');
});
return tsResult
.pipe(concat(output))
.pipe(gulp.dest(dest || './public/js'))
.pipe(new elixir.Notification('TypeScript Compiled!'));
})
.watch(assetPath + '/typescript/**');
});