-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
rollup.config.js
67 lines (64 loc) · 1.64 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
import pkg from './package.json';
import ts from 'rollup-plugin-ts';
import terser from '@rollup/plugin-terser';
const reference = '/// <reference types="./index.d.ts" />';
const nodeReference = '/// <reference types="./node.d.ts" />';
const banner = `
var dom = new jsdom.JSDOM('<!DOCTYPE html><html><body></body></html>');
var document = dom.window.document;
`;
const getPlugins = () => [
ts(),
terser({
output: {
comments: /reference/
}
})
];
export default [
{
plugins: getPlugins(),
input: 'src/index.ts',
output: [
{
file: 'web/isometric.js',
format: 'iife',
name: 'isometric'
},
{
file: pkg.exports['.'].require.default,
format: 'cjs',
banner: reference
},
{
file: pkg.exports['.'].import.default,
format: 'es',
banner: reference
}
]
},
{
plugins: getPlugins(),
input: 'src/index.ts',
output: [
{
file: pkg.exports['./node'].require.default,
format: 'cjs',
banner: `
${nodeReference}
var jsdom = require('jsdom');
${banner}
`
},
{
file: pkg.exports['./node'].import.default,
format: 'es',
banner: `
${nodeReference}
import jsdom from 'jsdom';
${banner}
`
}
]
}
];