forked from greengerong/rebirth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
164 lines (145 loc) · 3.92 KB
/
gulpfile.babel.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
158
159
160
161
162
163
164
import gulp from 'gulp';
import stubby from 'gulp-stubby-server';
import path from 'path';
import del from 'del';
import install from 'gulp-install';
import typedoc from 'gulp-typedoc';
import karma from 'karma';
import tslint from "gulp-tslint";
import browserSync from 'browser-sync';
import runSequence from 'run-sequence';
import sourcemaps from 'gulp-sourcemaps';
import gutil from 'gulp-util';
import webpack from 'webpack';
import webpackStream from 'webpack-stream';
import WebpackDevServer from 'webpack-dev-server';
import map from 'map-stream';
import concat from 'gulp-concat';
let browserSyncServer = browserSync.create();
let files = [
path.join(__dirname, './mocks/**/*.{yaml,js}')
];
gulp.task('install:npm', () => {
return gulp.src(['./package.json'])
.pipe(install());
});
gulp.task('mock', (cb) => {
const options = {
callback: (server, options) => {
server.get(1, function (err, endpoint) {
if (!err)
console.log(endpoint);
});
},
stubs: 8000,
tls: 8443,
admin: 8010,
relativeFilesPath: true,
files
};
stubby(options, cb);
});
gulp.task('clean:dist', () => {
return del([
'dist/**/*'
]);
});
gulp.task('clean:all', ['clean:dist'], () => {
return del([
'doc/**/*',
'typings/**/*',
'coverage/**/*'
]);
});
// issue
gulp.task('docs', function () {
return gulp
.src(['./src/**/*.ts', '!./src/**/!(*.spec.ts)'])
.pipe(typedoc({
"name": "rebirth",
"mode": "modules",
"out": "doc",
"theme": "default",
"ignoreCompilerErrors": "true",
"experimentalDecorators": "true",
"emitDecoratorMetadata": "true",
"target": "ES5",
"moduleResolution": "node",
"preserveConstEnums": "true",
"stripInternal": "true",
"suppressExcessPropertyErrors": "true",
"suppressImplicitAnyIndexErrors": "true",
"module": "commonjs"
}));
});
gulp.task('webpack:dev', ['clean:dist'], () => {
return gulp.src(['src/**/*.js', 'src/**/*.ts'])
.pipe(sourcemaps.init())
.pipe(webpackStream(require("./build/webpack.dev.js")))
.pipe(sourcemaps.write())
.pipe(gulp.dest('./dist'));
});
gulp.task('webpack:prod', ['clean:dist'], () => {
let prodConfig = Object.create(require("./build/webpack.prod.js"));
prodConfig.progress = true;
return gulp.src(['src/**/*.js', 'src/**/*.ts'])
.pipe(sourcemaps.init())
.pipe(webpackStream(prodConfig))
.pipe(sourcemaps.write())
.pipe(gulp.dest('./dist'));
});
gulp.task("dev", ['mock'], () => {
var devConfig = Object.create(require("./build/webpack.dev.js"));
return new WebpackDevServer(webpack(devConfig), {
stats: {
colors: true
},
hot: false,
quiet: false,
noInfo: false,
historyApiFallback: true,
inline: true,
colors: true
}).listen(3000, "localhost", function (err) {
if (err) throw new gutil.PluginError("webpack-dev-server", err);
gutil.log("[webpack-dev-server]", "http://localhost:3000/");
});
});
gulp.task("tslint", () => {
return gulp.src('src/**/*.ts')
.pipe(tslint({configuration: "./tslint.json"}))
.pipe(tslint({
formatter: "verbose"
}))
.pipe(tslint.report());
});
gulp.task('karma:debug', (cb) => {
new karma.Server({
configFile: __dirname + '/build/karma.conf.js',
singleRun: false,
autoWatch: true,
browsers: ['Chrome']
}, cb).start();
});
gulp.task('karma', (cb) => {
new karma.Server({
configFile: __dirname + '/build/karma.conf.js',
singleRun: true
}, cb).start();
});
gulp.task('serve:prod', () => {
browserSyncServer.init({
server: {
baseDir: "./dist"
}
});
});
gulp.task('install', ['install:npm']);
gulp.task('clean:install', ['clean:all', 'install']);
gulp.task('test', ['tslint', 'karma']);
gulp.task('build:dev', ['webpack:dev']);
gulp.task('build', ['test', 'webpack:prod']);
gulp.task('prod', function (cb) {
runSequence('build', 'serve:prod', cb);
});
gulp.task('default', ['build']);