-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.dist.js
74 lines (65 loc) · 1.81 KB
/
rollup.config.dist.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
import resolve from '@rollup/plugin-node-resolve';
import serve from 'rollup-plugin-serve';
import livereload from 'rollup-plugin-livereload';
import del from 'rollup-plugin-delete';
const globals = (id) => {
const globals = {};
if (/ol(\\|\/)/.test(id)) {
return id.replace(/\//g, '.').replace('.js', '');
} else if (id in globals) {
return globals[id];
}
return id;
};
export default function (commandOptions) {
const outputs = [
{
input: 'lib/DescribeFeatureType.js',
output: [
{
file: 'dist/DescribeFeatureType.js',
format: 'umd',
name: 'DescribeFeatureType',
globals: globals,
sourcemap: commandOptions.dev
}
],
plugins: [
del({ targets: 'dist/*' }),
resolve({
browser: true, // <-- suppress node-specific features
module: false
}),
commandOptions.dev &&
serve({
open: false,
verbose: true,
contentBase: ['', 'examples', 'data'],
historyApiFallback: `/${commandOptions.example || 'converter'}.html`,
host: 'localhost',
port: 3009,
// execute function after server has begun listening
onListening: function (server) {
const address = server.address();
// by using a bound function, we can access options as `this`
const protocol = this.https ? 'https' : 'http';
console.log(
`Server listening at ${protocol}://localhost:${address.port}/`
);
}
}),
commandOptions.dev &&
livereload({
watch: ['dist'],
delay: 2000
})
],
external: (id) => {
return /(ol(\\|\/))/.test(
id
);
}
}
];
return outputs;
}