forked from microsoft/cognitive-services-speech-sdk-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
96 lines (92 loc) · 2.96 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
(function () {
'use strict';
var gulp = require('gulp');
var ts = require('gulp-typescript');
var sourcemaps = require('gulp-sourcemaps');
var eslint = require('gulp-eslint');
var terser = require('gulp-terser');
var rename = require('gulp-rename');
var pump = require('pump');
var webpack = require('webpack-stream');
var dtsBundleWebpack = require('dts-bundle-webpack');
var tsProject = ts.createProject('tsconfig.json');
var tsProject2015 = ts.createProject('tsconfig.json', {
target: 'es2015',
module: 'esnext'
});
gulp.task('build', gulp.series(function build() {
return gulp.src([
'src/**/*.ts',
'microsoft.cognitiveservices.speech.sdk.ts'],
{ base: '.' })
.pipe(eslint({
formatter: 'prose',
configuration: 'eslint.json'
}))
.pipe(eslint.format())
.pipe(eslint.failAfterError())
.pipe(sourcemaps.init())
.pipe(tsProject())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('distrib/lib'));
}, function () {
return gulp.src('./external/**/*')
.pipe(gulp.dest('./distrib/lib/external/'));
}));
gulp.task('build2015', gulp.series(function build() {
return gulp.src([
'src/**/*.ts',
'microsoft.cognitiveservices.speech.sdk.ts'],
{ base: '.' })
.pipe(eslint({
formatter: 'prose',
configuration: 'eslint.json'
}))
.pipe(eslint.format())
.pipe(eslint.failAfterError())
.pipe(sourcemaps.init())
.pipe(tsProject2015())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('distrib/es2015'));
}, function () {
return gulp.src('./external/**/*')
.pipe(gulp.dest('./distrib/es2015/external/'));
}));
gulp.task('bundle', gulp.series('build', function bundle() {
return gulp.src('bundleApp.js')
.pipe(webpack({
output: { filename: 'microsoft.cognitiveservices.speech.sdk.bundle.js' },
devtool: 'source-map',
module: {
rules: [{
enforce: 'pre',
test: /\.js$/,
loader: 'source-map-loader'
}],
},
mode: 'none',
plugins: [
new dtsBundleWebpack({
name: 'microsoft.cognitiveservices.speech.sdk.bundle',
main: 'distrib/lib/microsoft.cognitiveservices.speech.sdk.d.ts',
out: '~/distrib/browser/microsoft.cognitiveservices.speech.sdk.bundle.d.ts',
outputAsModuleFolder: true,
})
]
}))
.pipe(gulp.dest('distrib/browser'));
}, function () {
return gulp.src('./src/audioworklet/speech-processor.js')
.pipe(gulp.dest('./distrib/browser'));
}));
gulp.task('compress', gulp.series('bundle', function (cb) {
return pump([
gulp.src('distrib/browser/microsoft.cognitiveservices.speech.sdk.bundle.js'),
rename(function (path) { path.basename = 'microsoft.cognitiveservices.speech.sdk.bundle-min'; }),
terser(),
gulp.dest('distrib/browser')
],
cb
);
}));
}());