-
Notifications
You must be signed in to change notification settings - Fork 263
/
rollup.config.mjs
79 lines (68 loc) · 1.98 KB
/
rollup.config.mjs
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
import commonjs from '@rollup/plugin-commonjs';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import globals from 'rollup-plugin-node-globals';
import builtins from 'rollup-plugin-node-builtins';
import typescript from '@rollup/plugin-typescript';
// import uglify from "@lopatnov/rollup-plugin-uglify"; // Uglify for ES5
import terser from '@rollup/plugin-terser'; // Uglify for ES6
import pluginList from './plugin-list.js';
// const pluginList = {};
// {name: path} // pure javascript
// {name: [path, true]} // javascript + typescript
let prefix = 'rex';
let outputs = [];
for (var key in pluginList) {
let inputConfig = pluginList[key];
let inputFile, useTypescript;
if (typeof (inputConfig) === 'string') {
inputFile = inputConfig;
useTypescript = false;
} else {
inputFile = inputConfig[0];
useTypescript = inputConfig[1];
}
// Export no-uglify files
let libName = `${prefix}${key}`;
let outFile = `./dist/${libName}.js`;
// console.log(inputFile)
// console.log(outFile)
// console.log(libName)
outputs.push({
input: inputFile,
output: {
file: outFile,
name: libName,
format: 'umd',
},
external: ['phaser'],
plugins: [
nodeResolve({
browser: true,
preferBuiltins: true
}),
commonjs(),
globals(),
builtins(),
(useTypescript) ? typescript({
target: 'es6',
}) : undefined,
]
})
// Export uglify files
let inputFile2 = outFile;
let outFile2 = `./dist/${libName}.min.js`;
outputs.push({
input: inputFile2,
output: {
file: outFile2,
// name: libName,
// format: 'umd',
},
external: ['phaser'],
plugins: [
// uglify()
terser()
]
})
}
export default outputs;