forked from rexrainbow/phaser3-rex-notes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
81 lines (68 loc) · 1.97 KB
/
rollup.config.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
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 babel from 'rollup-plugin-babel';
import typescript from '@rollup/plugin-typescript';
import { uglify } from "rollup-plugin-uglify";
// import { terser } from 'rollup-plugin-terser'; // Uglify for ES6
const pluginList = require('./plugin-list.js');
// {name: path} // pure javascript
// {name: [path, true]} // javascript + typescript
let outputs = [];
// Export no-uglify files
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];
}
let outFile = `./dist/rex${key}.js`;
let libName = `rex${key}`;
// 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: 'es5',
}) : undefined,
babel({
exclude: 'node_modules/**'
}),
]
})
let inputFile2 = outFile;
let outFile2 = `./dist/rex${key}.min.js`;
outputs.push({
input: inputFile2,
output: {
file: outFile2,
// name: libName,
// format: 'umd',
},
external: ['phaser'],
plugins: [
uglify()
]
})
}
export default outputs;