-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
81 lines (65 loc) · 2.17 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
/*
This file is the main entry point for defining Gulp tasks and using Gulp plugins
To learn more visit: https://github.com/gulpjs/gulp/blob/master/docs/README.md
*/
'use strict';
var gulp = require('gulp'),
os = require('os'),
ts = require('gulp-typescript'),
_ = require('lodash'),
del = require('del'),
dnx = require('gulp-dnx'),
livereload = require('gulp-livereload'),
gulpSequence = require('gulp-sequence'),
open = require('open'),
project = require('./project.json'),
packages = require('./package.json'),
app = './app',
releaseDir = project.webroot + '/app';
// The default task (called when you run `gulp` from CLI)
gulp.task('default', gulpSequence('clean', ['copy-deps','copy-templates','copy-libs','copy-content','scripts']));
gulp.task('serve', gulpSequence('default', ['watch', 'dnx-run']));
gulp.task('watch', function () {
livereload.listen();
gulp.watch(app + '/**/*', ['scripts', 'copy-templates']);
gulp.watch('./content/**/*', ['copy-content']);
gulp.watch('./Views/**/*', ['reload-site'])
});
gulp.task('dnx-run', dnx('kestrel'));
gulp.task('reload-site', function () {
livereload.reload();
});
gulp.task('copy-deps', function () {
var modulesToCopy = _.map(packages.dependencies, function (val, key) {
return './node_modules/' + key + '/**/*';
});
return gulp.src(modulesToCopy, { base: 'node_modules' })
.pipe(gulp.dest(releaseDir + '/lib/'));
});
gulp.task('copy-libs', function () {
return gulp.src("./lib/**/*")
.pipe(gulp.dest(releaseDir + '/lib/'));
});
gulp.task('copy-content', function () {
return gulp.src("./content/**/*")
.pipe(gulp.dest(releaseDir + '/content/'));
});
gulp.task('copy-templates', function () {
return gulp.src(app + '/**/*.html')
.pipe(gulp.dest(releaseDir));
});
gulp.task("scripts", function () {
var tsProj = ts.createProject(app + '/tsconfig.json', {
typescript: require('typescript')
});
var tsResult = gulp.src(app + '/**/*.ts')
.pipe(ts(tsProj))
return tsResult.js.pipe(gulp.dest(releaseDir))
.pipe(livereload());
});
gulp.task("clean", function () {
del.sync([releaseDir]);
});
gulp.task('open-browser', function(){
open('http://localhost:5001');
});