-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathrollup.config.ts
79 lines (71 loc) · 1.93 KB
/
rollup.config.ts
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 * as path from 'path';
import * as fs from 'fs';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import typescript from 'rollup-plugin-typescript2';
import { string } from 'rollup-plugin-string';
import preprocess from 'rollup-plugin-preprocess';
// setup some common values
const pkg = require('./package.json');
const prod = process.env.NODE_ENV === 'production';
const compiled = (new Date()).toUTCString().replace(/GMT/g, 'UTC');
const banner = `/*!
* ${pkg.name} - v${pkg.version}
* Compiled ${compiled}
*
* ${pkg.name} is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
*/\n`;
// create the common config values
const plugins = [
string({
include: [
'**/*.vert',
'**/*.frag',
'**/*.glsl',
],
exclude: 'node_modules/**',
}),
preprocess({
include: [
'**/*.ts',
],
exclude: 'node_modules/**',
context: {
DEBUG: !prod,
},
}),
typescript(),
resolve(),
commonjs(),
];
const output = {
format: 'umd',
sourcemap: false,
banner,
globals: {
'resource-loader': 'Loader',
},
};
// generate configs for all the bundles
const bundleDir = 'bundles';
const dirs = fs.readdirSync(bundleDir);
const bundles = [];
for (let i = 0; i < dirs.length; ++i)
{
const dirname = dirs[i];
const folder = path.join(bundleDir, dirname);
if (fs.existsSync(path.join(folder, 'index.ts')))
{
const ext = dirname === 'gl-tiled' ? '' : `.${dirname}`;
const file = path.join('dist', `gl-tiled${ext}.js`);
const name = `glTiled${ext}`;
bundles.push({
external: ['resource-loader'],
input: path.join('bundles', dirname, 'index.ts'),
plugins,
output: Object.assign({ file, name }, output),
});
}
}
export default bundles;