-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
92 lines (71 loc) · 2.45 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
var gulp = require('gulp'),
ts = require('gulp-typescript'),
sourcemaps = require('gulp-sourcemaps');
var browserSync = require('browser-sync');
var BROWSER_SYNC_RELOAD_DELAY = 500;
var historyApiFallback = require('connect-history-api-fallback');
//browsersync
gulp.task('browser-sync', function () {
browserSync.init({
server: {
baseDir: "./",
middleware: [ historyApiFallback() ],
//directory: true remove middleware in order to work directory of projects
},
port:3200
});
// for more browser-sync config options: http://www.browsersync.io/docs/options/
/*
browserSync({
// informs browser-sync to proxy our expressjs app which would run at the following location
proxy: 'http://localhost:8082',
// informs browser-sync to use the following port for the proxied app
// notice that the default port is 3000, which would clash with our expressjs
port: 4200,
// open the proxied app in chrome
browser: ['chrome']
});
*/
});
//var browserSync = require('browser-sync').create();
//var reload = browserSync.reload;
//gulp.watch("*.html").on("change", reload);
gulp.task('js', function () {
return gulp.src('app/**/*.js')
// do stuff to JavaScript files
//.pipe(uglify())
//.pipe(gulp.dest('...'));
});
gulp.task('css', function () {
return gulp.src('app/**/*.css')
.pipe(browserSync.reload({ stream: true }));
})
gulp.task('bs-reload', function () {
browserSync.reload();
});
gulp.task('browser-synch-watch', ['browser-sync'], function () {
gulp.watch('app/**/*.js', ['js', 'bs-reload']);
gulp.watch('app/**/*.css', ['css']);
gulp.watch('app/**/*.html', ['bs-reload']);
gulp.watch('./*.html', ['bs-reload']);
});
var tsServerProject = ts.createProject({
declarationFiles: false,
noResolve: false,
module: 'commonjs',
target: 'ES5'
});
var srcServer = 'app/**/*.ts'
gulp.task('default', ['compile-server','browser-synch-watch'], watchServer);
gulp.task('compile-server', compileServer);
function watchServer(params) {
gulp.watch(srcServer, ['compile-server']);
}
function compileServer(params) {
var tsResult = gulp.src(srcServer)
.pipe(sourcemaps.init())
.pipe(tsServerProject());
return tsResult.js
.pipe(sourcemaps.write('./source-maps'))
.pipe(gulp.dest('app/'));
}