forked from MTG/essentia.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.min.js
95 lines (89 loc) · 2.4 KB
/
rollup.config.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import typescript from 'rollup-plugin-typescript2';
import {terser} from "rollup-plugin-terser";
// global var to assign build settings object
let EXPORT_BUILD_OPTS;
// code snippet to accept custom target build paths if specified in cmd-line.
let DIST_DIR;
if (!("DIST_DIR" in process.env)) {
DIST_DIR = "dist";
} else {
DIST_DIR = process.env.DIST_DIR;
};
// default configuration options for building Essentia.js core JS API and add-on modules
let defaultBuildOpts = [{
input: 'src/typescript/core_api.ts', // our source file
output: [
{
file: DIST_DIR + '/essentia.js-core.es.min.js',
format: 'es' // the preferred format
},
{
file: DIST_DIR + '/essentia.js-core.min.js',
format: 'iife',
name: 'Essentia' // the global which can be used in a browser
}
],
plugins: [
typescript({
typescript: require('typescript'),
}),
]
}, {
input: 'src/typescript/plot.ts', // our source file
output: [
{
file: DIST_DIR + '/essentia.js-plot.es.min.js',
format: 'es' // the preferred format
},
{
file: DIST_DIR + '/essentia.js-plot.min.js',
format: 'iife',
name: 'EssentiaPlot' // the global which can be used in a browser
}
],
plugins: [
typescript({
typescript: require('typescript'),
}),
]
}, {
input: 'src/typescript/extractor.ts', // our source file
output: [
{
file: DIST_DIR + '/essentia.js-extractor.es.min.js',
format: 'es' // the preferred format
},
{
file: DIST_DIR + '/essentia.js-extractor.min.js',
format: 'iife',
name: 'EssentiaExtractor' // the global which can be used in a browser
}
],
plugins: [
typescript({
typescript: require('typescript'),
}),
]
},
]
// code snippet to adapt cmd-line options for building builds with/without add-on modules.
let IS_ADDON;
if (!("ESSENTIAJS_ADDON" in process.env)) {
EXPORT_BUILD_OPTS = defaultBuildOpts;
} else {
IS_ADDON = Boolean(Number(process.env.ESSENTIAJS_ADDON));
if (IS_ADDON) {
EXPORT_BUILD_OPTS = defaultBuildOpts;
} else {
defaultBuildOpts.forEach(function (item, index) {
// remove all the add-on modules from build settings
if (index >= 0) defaultBuildOpts.pop();
});
EXPORT_BUILD_OPTS = defaultBuildOpts;
}
};
// add code compression to the build settings using rollup-terser plugin
EXPORT_BUILD_OPTS.forEach(function(item, index) {
item.plugins.push(terser());
});
export default EXPORT_BUILD_OPTS;