forked from AlphaWallet/AlphaWallet-web3-provider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
64 lines (58 loc) · 1.88 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
const gulp = require('gulp'),
babelify = require('babelify'),
browserify = require('browserify'),
buffer = require('vinyl-buffer'),
del = require('del'),
minify = require('gulp-minify'),
size = require('gulp-size'),
source = require('vinyl-source-stream'),
config = {
name: 'AlphaWallet',
fileTypes: {
all: '**/*',
js: '**/*.js',
main: 'index.js'
},
source: {
baseDir: 'src'
},
staging: {
baseDir: 'staging'
},
distribution: {
baseDir: 'dist',
javascript: 'js'
}
};
gulp.task('clean:stage', function () {
let stagingDir = `${config.staging.baseDir}/${config.fileTypes.all}`;
return del(stagingDir);
});
gulp.task('clean:dist', function () {
let distributionDir = `${config.distribution.baseDir}/${config.fileTypes.all}`;
return del(distributionDir);
});
gulp.task('clean', gulp.series('clean:dist', 'clean:stage'))
gulp.task('javascript', function () {
let sourceDir = `${config.source.baseDir}/${config.fileTypes.js}`,
stagingDir = `${config.staging.baseDir}`;
return gulp.src(sourceDir)
.pipe(gulp.dest(stagingDir));
});
gulp.task('bundle:javascript', gulp.series('javascript', function () {
let mainFile = `${config.staging.baseDir}/${config.fileTypes.main}`,
distributionDir = `${config.distribution.baseDir}`;
return browserify(mainFile)
.transform(babelify, { presets: ['env'] })
.bundle()
.pipe(source(config.name + '.js'))
.pipe(buffer())
.pipe(minify({
mangle: {
reserved: [ 'AlphaWalletWeb3Provider' ]
}
}))
.pipe(size())
.pipe(gulp.dest(distributionDir));
}));
gulp.task('build', gulp.series('clean:dist', 'clean:stage', `bundle:javascript`))