This repository has been archived by the owner on Feb 20, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
75 lines (64 loc) · 1.92 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
'use strict';
var gulp = require('gulp');
var onejsCompiler = require('gulp-onejs-compiler');
var tsc = require('gulp-tsc');
var flatten = require('gulp-flatten');
var less = require('gulp-less');
var csstojs = require('gulp-csstojs');
var filter = require('gulp-filter');
var webserver = require('gulp-webserver');
var rimraf = require('gulp-rimraf');
var paths = {
buildPath: 'build',
appPath: 'app',
staticFiles: [
'node_modules/requirejs/require.js',
'src/index.html',
'node_modules/winjs/js/WinJS.js',
'node_modules/winjs/css/ui-dark.css',
'node_modules/winjs/fonts/Symbols.ttf',
'src/typings/winjs.d.ts']
};
gulp.task('clean', function() {
return gulp.src([paths.buildPath, paths.appPath], {read: false})
.pipe(rimraf());
});
gulp.task('tsc-preprocess', ['clean'], function() {
var lessFilter = filter('**/*.less');
return gulp.src(['src/**/*'])
.pipe(lessFilter)
.pipe(less())
.pipe(csstojs({
typeScript: true
}))
.pipe(lessFilter.restore())
.pipe(onejsCompiler())
.pipe(gulp.dest(paths.buildPath + '/ts'));
});
gulp.task('tsc', ['tsc-preprocess'], function() {
return gulp.src(paths.buildPath + '/ts/**/*.ts')
.pipe(tsc({
module: 'amd'
}))
.pipe(gulp.dest(paths.appPath));
});
gulp.task('copy-static-files', ['clean', 'tsc'], function() {
return gulp.src(paths.staticFiles)
.pipe(gulp.dest(paths.appPath));
});
gulp.task('serve', function() {
gulp.src(paths.appPath)
.pipe(webserver({
livereload: false,
directoryListing: {
enable: false,
path: paths.appPath
},
open: true,
fallback: 'index.html'
}));
});
gulp.task('watch', function() {
gulp.watch('src/**/*', ['default']);
});
gulp.task('default', ['tsc', 'copy-static-files']);