forked from RobotWebTools/ros3djs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
120 lines (114 loc) · 2.56 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
const rollup = require('rollup');
// plugin that transpiles output into commonjs format
const commonjs = require('rollup-plugin-commonjs');
// plugin that transpiles es6 to es5 for legacy platforms
const buble = require('rollup-plugin-buble');
// plugin that shows output file info
const filesize = require('rollup-plugin-filesize');
/// plugin that resolves node module imports
const resolve = require('rollup-plugin-node-resolve');
// plugin that minifies and obfuscates code
const uglify = require('rollup-plugin-uglify');
const pkg = require('./package.json');
const input = 'src-esm/index.js';
const browserGlobals = {
roslib: 'ROSLIB',
};
const moduleGlobals = {
roslib: 'ROSLIB',
};
const outputFiles = {
commonModule: pkg.main,
esModule: pkg.module,
browserGlobal: './build/ros3d.js',
browserGlobalMinified: './build/ros3d.min.js',
};
export default [
// build main as ES5 in CommonJS format for compatibility
{
input,
output: {
name: 'ROS3D',
file: outputFiles.commonModule,
format: 'cjs',
globals: {
...moduleGlobals,
}
},
external: [
...Object.keys(moduleGlobals)
],
plugins: [
resolve({ browser: true }),
commonjs(),
buble(),
filesize(),
],
},
// build module as ES5 in ES module format for modern tooling
{
input,
output: {
name: 'ROS3D',
file: outputFiles.esModule,
format: 'es',
globals: {
...moduleGlobals,
}
},
external: [
...Object.keys(moduleGlobals)
],
plugins: [
resolve({ browser: true }),
commonjs(),
buble(),
filesize(),
],
},
// build browser as IIFE module for script tag inclusion, unminified
// Usage:
// <script src="../build/ros3d.js"></script>
{
input,
output: {
name: 'ROS3D',
file: outputFiles.browserGlobal,
format: 'iife',
globals: {
...browserGlobals,
},
},
external: [
...Object.keys(browserGlobals),
],
plugins: [
resolve({ browser: true }),
commonjs(),
filesize(),
],
},
// build browser as IIFE module for script tag inclusion, minified
// Usage:
// <script src="../build/ros3d.min.js"></script>
{
input,
output: {
name: 'ROS3D',
file: outputFiles.browserGlobalMinified,
format: 'iife',
globals: {
...browserGlobals,
},
},
external: [
...Object.keys(browserGlobals),
],
plugins: [
resolve({ browser: true }),
commonjs(),
filesize(),
uglify(),
],
},
];