-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
121 lines (102 loc) · 3.59 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
"use strict";
//******************************************************************************
//* DEPENDENCIES
//******************************************************************************
var gulp = require("gulp"),
tslint = require("gulp-tslint"),
tsc = require("gulp-typescript"),
runSequence = require("run-sequence"),
browserify = require("browserify"),
source = require("vinyl-source-stream"),
buffer = require("vinyl-buffer"),
cleanCSS = require("gulp-clean-css"),
concat = require("gulp-concat");
//******************************************************************************
//* LINT ALL
//******************************************************************************
gulp.task("lint", function() {
var config = { emitError: (process.env.CI) ? true : false };
return gulp.src([
"src/**/**.ts",
"test/**/**.test.ts"
])
.pipe(tslint())
.pipe(tslint.report("verbose", config));
});
//******************************************************************************
//* BUILD SOURCE
//******************************************************************************
var tsLibProject = tsc.createProject("tsconfig.json");
gulp.task("build", function() {
return gulp.src([
"typings/index.d.ts",
"node_modules/reflect-metadata/reflect-metadata.d.ts",
"node_modules/inversify-dts/inversify-devtools/inversify-devtools.d.ts",
"src/**/**.ts"
])
.pipe(tsc(tsLibProject))
.on("error", function (err) {
process.exit(1);
})
.js.pipe(gulp.dest("temp/"));
});
//******************************************************************************
//* BUNDLE SOURCE
//******************************************************************************
gulp.task("bundle", function() {
var mainFilePath = "temp/main.js";
var outputFolder = "dist";
var outputFileName = "app.js";
var bundler = browserify({
debug: true
});
// TS compiler options are in tsconfig.json file
return bundler.add(mainFilePath)
.bundle()
.pipe(source(outputFileName))
.pipe(buffer())
.pipe(gulp.dest(outputFolder));
});
//******************************************************************************
//* BUNDLE CSS
//******************************************************************************
gulp.task("bundle-css", [ "copy-fonts", "copy-main", "copy-media" ], function() {
return gulp.src([
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"node_modules/font-awesome/css/font-awesome.min.css",
"node_modules/inversify-devtools/style/scrollbar.css",
"node_modules/inversify-devtools/style/tree.css",
"node_modules/inversify-devtools/style/site.css"
])
.pipe(concat("app.css"))
.pipe(cleanCSS())
.pipe(gulp.dest("dist/"));
});
gulp.task("copy-fonts", function() {
return gulp.src([
"node_modules/font-awesome/fonts/**/*"
]).pipe(gulp.dest("dist/fonts"));
});
gulp.task("copy-media", function() {
return gulp.src([
"media/**/*"
]).pipe(gulp.dest("dist/media"));
});
gulp.task("copy-main", function() {
return gulp.src([
"devtools.html",
"index.html",
"manifest.json"
]).pipe(gulp.dest("dist"));
});
//******************************************************************************
//* TASK GROUPS
//******************************************************************************
gulp.task("default", function (cb) {
runSequence(
"lint",
"build",
"bundle",
"bundle-css",
cb);
});