-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
47 lines (36 loc) · 1.14 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
'use strict';
var gulp = require("gulp");
var ts = require("gulp-typescript");
var tsProject = ts.createProject("tsconfig.json");
var browserify = require("browserify");
var buffer = require('vinyl-buffer');
var source = require('vinyl-source-stream');
var sourcemaps = require('gulp-sourcemaps');
var terser = require('gulp-terser-js');
var tsify = require("tsify");
function taskBundle(name, options) {
gulp.task(name, function () {
var result = browserify({
basedir: '.',
debug: false,
entries: [ './src.ts/' ],
cache: {},
packageCache: {},
})
.plugin(tsify)
.bundle()
.pipe(source(options.filename))
if (options.minify) {
result = result.pipe(buffer())
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(terser())
.pipe(sourcemaps.write('./'))
}
result = result.pipe(gulp.dest("dist"));
return result;
});
}
// Creates dist/mxw-ledger-signer.js
taskBundle("default", { filename: "mxw-ledger-signer.js", minify: false });
// Creates dist/mxw-ledger-signer.min.js
taskBundle("minified", { filename: "mxw-ledger-signer.min.js", minify: true });