forked from TomaszRewak/ML-games
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
57 lines (49 loc) · 1.57 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
51
52
53
54
55
56
57
var gulp = require('gulp');
var ts = require('gulp-typescript');
var browserify = require('gulp-browserify');
var clean = require('gulp-clean');
var rename = require('gulp-rename');
var sequence = require('gulp-sequence');
var less = require('gulp-less');
var banner = require('gulp-banner');
function swallowError(error) {
console.log(error.toString())
this.emit('end')
}
gulp.task('clear', function () {
return gulp.src('Build').pipe(clean());
});
gulp.task('typescript', function () {
return gulp.src('Source/Scripts/**/*.ts')
.pipe(ts({ target: 'ES6', module: 'commonjs' }))
.on('error', swallowError)
.js
.pipe(gulp.dest('Build'));
});
gulp.task('browserify', function () {
return gulp.src('Build/Main.js')
.pipe(browserify())
.on('error', swallowError)
.pipe(banner('// ******************************************** \n' +
'// * By Tomasz Rewak (tomasz-rewak.com, linkedin.com/in/tomaszrewak) \n' +
'// * Copyright (c) 2016 Tomasz Rewak \n' +
'// * Released under the The MIT License (MIT). \n' +
'// ******************************************** \n\n\n'
))
.pipe(rename('app.js'))
.pipe(gulp.dest('Site/'));
});
gulp.task('styles', function () {
return gulp.src('Source/Styles/*.less')
.pipe(less())
.on('error', swallowError)
.pipe(gulp.dest('Site/'))
});
gulp.task('build', function (callback) {
sequence('clear', 'typescript', 'browserify', 'clear')(callback);
});
gulp.task('watch', function () {
gulp.watch('Source/Scripts/**/*.ts', ['build'])
gulp.watch('Source/Styles/*.less', ['styles'])
});
gulp.task('default', ['build', 'styles']);