-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrollup.config.mts
80 lines (76 loc) · 2.29 KB
/
rollup.config.mts
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
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import typescript from '@rollup/plugin-typescript';
import { RollupOptions } from 'rollup';
import dts from 'rollup-plugin-dts';
import peer_deps_external from 'rollup-plugin-peer-deps-external';
import pkg from './package.json' assert { type: 'json' };
function non_minified_file(path: string): string {
return path.replace(".min.js", ".js");
}
/**
* Comment with library information to be appended in the generated bundles.
*/
const banner = `/**
* ${pkg.name} ${pkg.version}
* (c) ${pkg.author.name} ${pkg.author.email}
* Released under the ${pkg.license} License.
*/
`.trim();
const options: RollupOptions[] = [
{
input: 'src/index.ts',
output: [
{
file: non_minified_file(pkg.exports['.'].import),
format: 'esm',
sourcemap: true
},
{
file: pkg.exports['.'].import,
format: 'esm',
sourcemap: true,
plugins: [terser()]
},
{
banner,
file: non_minified_file(pkg.exports['.'].system),
format: 'system',
sourcemap: true
},
{
banner,
file: pkg.exports['.'].system,
format: 'system',
sourcemap: true,
plugins: [terser()]
},
{
banner,
file: pkg.exports['.'].require,
format: 'commonjs',
sourcemap: true
},
{
file: pkg.browser,
format: 'umd',
name: 'EIGHT',
sourcemap: true
}
],
plugins: [
// Allows us to consume libraries that are CommonJS.
commonjs(),
peer_deps_external() as Plugin,
resolve(),
typescript({ tsconfig: './tsconfig.json', exclude: ['**/*.spec.ts'], noEmitOnError: true })
]
},
{
input: 'dist/esm/types/src/index.d.ts',
output: [{ file: pkg.types, format: "esm" }],
plugins: [dts()],
}
];
export default options;