-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.bundle.config.js
83 lines (76 loc) · 2.31 KB
/
rollup.bundle.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
import pkg from './package.json';
import licenses from './dependecies-license.json';
import typescript from 'rollup-plugin-typescript2';
import {nodeResolve} from '@rollup/plugin-node-resolve';
import {terser} from 'rollup-plugin-terser';
import commonjs from '@rollup/plugin-commonjs';
const my_license = {
"name": pkg.name,
"version": pkg.version,
"homepage": pkg.homepage,
"copy": `Copyright (c) 2021 ${pkg.author.name}`,
"license": pkg.license,
"dependencies": licenses
}
const license_text = "/*!\n" + create_license_text(my_license) + " */";
export default [
{
input: 'src/bundle.ts',
output: [
{
name: 'domsubi',
globals: { sodiumjs: 'Sodium' },
file: 'dist/domsubi.umd.js',
format: 'umd',
},
{
name: 'domsubi',
globals: { sodiumjs: 'Sodium' },
file: 'docs/domsubi.umd.js',
format: 'umd',
},
{
file: 'dist/domsubi.min.js',
format: 'esm',
}
].map((o) => Object.assign({
plugins: [terser({ module: true })],
sourcemap: true,
banner: license_text
},o)),
plugins: [
nodeResolve({
browser: true,
transformMixedEsModules: true
}),
commonjs({
exclude: ".ts"
}),
typescript({
tsconfigOverride: {
compilerOptions: {
module: "es2020",
target: "es2020",
declaration: false,
moduleResolution: "node"
}
}
})
]
}
];
function create_license_text(data, required_by) {
const name = data.version ? `${data.name} v${data.version}` : data.name;
const next = data.dependencies;
const text = [
required_by ? `${name} (required by ${required_by})` : name,
data.homepage,
data.copy,
`License: ${data.license}`
]
.map((s) => ` * ${s}\n`)
.join("");
return next
? text.concat(" *\n", next.map((d) => create_license_text(d, data.name)).join(" *\n"))
: text;
}