-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
157 lines (142 loc) · 4.73 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
var gulp = require("gulp");
// remove all __extends declarations except the first one
var cleants = require('gulp-clean-ts-extends');
var uglify = require("gulp-uglify");
var ts = require("gulp-typescript");
var concat = require("gulp-concat");
var expect = require('gulp-expect-file');
var replace = require("gulp-replace");
var config = require("./config.json");
var rename = require("gulp-rename");
var sourcemaps = require('gulp-sourcemaps');
var merge = require("merge2");
var notify = require("gulp-notify");
var path = require("path");
var tslint = require("gulp-tslint");
gulp.task("tslint", function () {
return gulp.src("./src/library/**/*.ts")
.pipe(tslint({
formatter: "verbose",
configuration: "./tslint.json"
}))
.pipe(tslint.report());
});
gulp.task("gen-dts", function () {
var tsResult = gulp.src(config.core.typescript).
pipe(ts({
sortOutput: true,
noExternalResolve: true,
target: 'ES5',
declarationFiles: true,
typescript: require('typescript'),
experimentalDecorators: true
}));
return merge([
tsResult.dts
.pipe(concat(config.build.declarationFilename))
.pipe(gulp.dest(config.build.outputDirectory))
//, tsResult.js
// .pipe(gulp.dest(config.build.srcOutputDirectory))
])
/*var res = gulp.src(config.core.typescript)
.pipe(ts({
sortOutput: true,
target: "ES5",
experimentalDecorators: true,
typescript: require('typescript'),
removeComments: true
}));
return merge([
res.dts
.pipe(concat(config.build.declarationFilename))
.pipe(gulp.dest(config.build.outputDirectory))
//, res.js
// .pipe(concat(config.build.filename))
// .pipe(gulp.dest(config.build.outputDirectory))
])*/
});
gulp.task("build", function () {
return merge(
gulp.src(config.core.files2)
.pipe(expect({
errorOnFailure: true,
reportMissing: true
}, config.core.files2))
)
.pipe(concat(config.build.filename))
.pipe(cleants())
.pipe(replace(/var\s__extends[\s\S]+?\};/g, ""))
.pipe(replace(/var\s__decorate[\s\S]+?\};/g, ""))
.pipe(addModuleExports("MonkeyBrush"))
.pipe(gulp.dest(config.build.outputDirectory))
.pipe(rename(config.build.minFilename))
.pipe(uglify())
.pipe(gulp.dest(config.build.outputDirectory));
});
gulp.task("typescript", ["gen-dts"/*, "build"*/], function(cb) {
cb();
});
var webserver = require('gulp-webserver');
gulp.task("build-debug", function() {
var tsResult = gulp.src(config.core.ts_files)
// .pipe(sourcemaps.init()) // This means sourcemaps will be generated
.pipe(ts({
sortOutput: true,
target: "ES5",
experimentalDecorators: true,
removeComments: true // TODO: SOURCEMAPS!!
}))
/*.on("error", notify.onError({
message: "Error: <%= error.message %>",
title: "Error running something"
}))*/;
return tsResult.js
.pipe(concat('output.js'))
.pipe(cleants())
//.pipe(replace(/var\s__extends[\s\S]+?\};/g, ""))
//.pipe(replace(/var\s__decorate[\s\S]+?\};/g, ""))
//.pipe(addModuleExports("MonkeyBrush"))
//.pipe(sourcemaps.write())
.pipe(gulp.dest(config.build.outputDirectory))
/*.pipe(notify({
title: "monkeybrush.js",
message: "Code OK",
icon: path.join(__dirname, '_images/logo.png')
}))*/;
});
gulp.task("watch-ts", ["build-debug", "webserver"], function() {
gulp.watch(config.core.typescript, ["build-debug"]);
});
gulp.task("watch", ["build-debug"], function() {
gulp.watch(config.core.typescript, ["build-debug"]);
});
gulp.task('webserver', function() {
gulp.src('./')
.pipe(webserver({
livereload: true,
open: true,
fallback: 'index.html'
}));
});
var typedoc = require("gulp-typedoc");
gulp.task("typedoc", function() {
return gulp
.src(config.core.ts_files)
.pipe(typedoc({
// TypeScript options (see typescript docs)
module: "commonjs",
target: "es5",
includeDeclarations: true,
experimentalDecorators: true,
// Output options (see typedoc docs)
out: "./doc",
// TypeDoc options (see typedoc docs)
name: "Monkey Brush",
readme: "./READMEDOC.md",
//theme: "minimal",
mode: "file",
plugins: [],
ignoreCompilerErrors: false,
version: true
}));
});