-
Notifications
You must be signed in to change notification settings - Fork 226
/
bundle.js
37 lines (35 loc) · 1.24 KB
/
bundle.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
var browserify = require('browserify')
, babelify = require('babelify')
, path = require('path')
, fs = require('fs')
, exorcist = require('exorcist')
, basePath = './'
, entryFile = './Source/Main.js'
, distFile = path.join(__dirname, basePath, 'dist/CesiumMeshVisualizer.js')
, distMinFile = path.join(__dirname, basePath, 'dist/CesiumMeshVisualizer.min.js')
, mapfile = path.join(__dirname, basePath, 'dist/CesiumMeshVisualizer.js.map')
, minMapfile = path.join(__dirname, basePath, 'dist/CesiumMeshVisualizer.min.js.map');
browserify(entryFile, {
debug: true,
standalone: "CesiumMeshVisualizer",
basedir: './'
})
.transform(babelify.configure({
presets: ['es2015']
}))
.bundle()
.pipe(exorcist(mapfile))
.pipe(fs.createWriteStream(distFile, 'utf8'))
.on('close', function (err) {
var UglifyJS = require('uglify-js')
var result = UglifyJS.minify(distFile, {
inSourceMap: mapfile,
outSourceMap: path.basename(minMapfile)
});
if (result.error) {
console.trace(result.error)
} else {
fs.writeFileSync(distMinFile, result.code);
fs.writeFileSync(minMapfile, result.map);
}
})