This repository has been archived by the owner on Dec 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 58
/
build.js
69 lines (60 loc) · 1.92 KB
/
build.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
var fs = require("fs")
var browserify = require("browserify")
const srcDir = 'src/'
const buildDir = 'dist/'
const babelPresets = ["env", "react"]
const standaloneName = 'ethereumjs'
const packages = [
'ethereumjs-all',
'ethereumjs-vm',
'ethereumjs-tx',
'ethereumjs-icap',
'ethereumjs-wallet',
'ethereumjs-wallet-hd',
'ethereumjs-wallet-thirdparty',
'ethereumjs-abi'
]
packages.forEach(function(name) {
var baseName = name.replace('-hd', '').replace('-thirdparty', '')
var version
if (name === 'ethereumjs-all') {
var date = new Date()
var day = date.getDate()
day = (day < 10 ? "0" : "") + day
version = String(date.getFullYear()) + '-' + String(date.getMonth() + 1) + '-' + String(day)
} else {
version = require('./node_modules/' + baseName + '/package.json').version
}
var baseOutPath = buildDir + name + '/' + name + '-' + version
fs.open(baseOutPath + '.js', 'wx', (err, fd) => {
console.log(`\n***${name}***`)
if (err) {
console.log(`Omitting debug version package ${baseOutPath}.js (file exists)`)
return
} else {
console.log(`Creating debug version package ${baseOutPath}.js`)
}
var bundleFs = fs.createWriteStream('', { fd: fd })
browserify(srcDir + name + '.js', {
standalone: standaloneName,
debug: true
}).transform("babelify", {presets: babelPresets})
.bundle()
.pipe(bundleFs)
})
fs.open(baseOutPath + '.min.js', 'wx', (err, fd) => {
if (err) {
console.log(`Omitting minified package ${baseOutPath}.min.js (file exists)`)
return
} else {
console.log(`Creating minified package ${baseOutPath}.min.js`)
}
bundleFs = fs.createWriteStream('', { fd: fd })
browserify(srcDir + name + '.js', {
standalone: standaloneName,
}).transform("babelify", {presets: babelPresets})
.transform('uglifyify', { global: true })
.bundle()
.pipe(bundleFs)
})
})