-
Notifications
You must be signed in to change notification settings - Fork 101
/
gulpfile.cjs
79 lines (76 loc) · 2.47 KB
/
gulpfile.cjs
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
(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');
gulp.task('build', gulp.series(function build() {
return gulp.src([
'src/**/*.ts',
'microsoft.cognitiveservices.speech.sdk.ts',
'!src/common.browser/__mocks__/',
'!src/common.browser/__mocks__/**'],
{ 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('./src/audioworklet/speech-processor.js')
.pipe(gulp.dest('./distrib/lib/src/common.browser'));
}));
gulp.task('bundle', gulp.series('build', function bundle() {
return gulp.src('bundleApp.js')
.pipe(webpack({
entry: {
'microsoft.cognitiveservices.speech.sdk.bundle': './bundleApp.js',
},
output: {
filename: '[name].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
);
}));
}());