forked from ngageoint/opensphere
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vendor-min.js
executable file
·72 lines (63 loc) · 1.71 KB
/
vendor-min.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
70
71
72
#!/usr/bin/env node
'use strict';
const resolver = require('opensphere-build-resolver/utils');
const Compiler = require('google-closure-compiler').compiler;
/**
* Resources for tuiEditor
* @type {Array<Object>}
*/
const tuiEditorResources = [
{
source: resolver.resolveModulePath('to-mark/dist', __dirname),
scripts: ['to-mark.min.js']
},
{
source: resolver.resolveModulePath('highlight.js/lib', __dirname),
scripts: ['highlight.js']
},
{
source: resolver.resolveModulePath('squire-rte/build', __dirname),
scripts: ['squire.js']
},
{
source: resolver.resolveModulePath('codemirror/lib', __dirname),
scripts: ['codemirror.js']
},
{
source: resolver.resolveModulePath('tui-code-snippet/dist', __dirname),
scripts: ['tui-code-snippet.min.js']
},
{
source: resolver.resolveModulePath('tui-editor/dist', __dirname),
scripts: [
'tui-editor-Editor.min.js',
'tui-editor-extTable.min.js'
]
}
];
/**
* @param {Array<Object>} resources
* @param {string} output
* @param {string=} opt_optimzationLevel
*/
var vendorMinify = function(resources, output, opt_optimzationLevel) {
var fileList = [];
resources.forEach(function(lib) {
lib.scripts.forEach(function(script) {
fileList = fileList.concat(lib.source + '/' + script);
});
});
var compiler = new Compiler({
js: fileList,
compilation_level: opt_optimzationLevel || 'SIMPLE_OPTIMIZATIONS',
js_output_file: output
});
compiler.run((exit, out, err) => {
if (exit) {
process.stderr.write(err, () => process.exit(1))
} else {
process.stdout.write('Yay it worked\n');
}
})
};
vendorMinify(tuiEditorResources, 'vendor/os-minified/os-tui-editor.min.js');