Repository navigation
Expand file tree
/
Copy pathrollup.config.mjs
More file actions
executable file
·74 lines (70 loc) · 1.67 KB
/
Copy pathrollup.config.mjs
File metadata and controls
executable file
·74 lines (70 loc) · 1.67 KB
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
import commonjs from '@rollup/plugin-commonjs';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import typescript from '@rollup/plugin-typescript';
import dts from 'rollup-plugin-dts';
import fs from 'node:fs';
const packageJson = JSON.parse(fs.readFileSync(new URL('./package.json', import.meta.url), 'utf8'));
function buildPlugins({ minify = false, declarations = false } = {}) {
const plugins = [
typescript({
tsconfig: './tsconfig.json',
declaration: declarations,
declarationDir: declarations ? 'dist' : undefined,
sourceMap: true,
}),
nodeResolve({ preferBuiltins: false }),
commonjs(),
];
if (minify) plugins.push(terser());
return plugins;
}
const external = ['axios', 'crypto-js', 'jose', 'crypto'];
export default [
{
input: 'src/index.ts',
external,
output: {
file: packageJson.main,
format: 'cjs',
exports: 'named',
sourcemap: true,
},
plugins: buildPlugins({ declarations: true }),
},
{
input: 'src/index.ts',
external,
output: {
file: packageJson.module,
format: 'es',
sourcemap: true,
},
plugins: buildPlugins(),
},
{
input: 'src/index.ts',
external,
output: {
file: 'dist/index.umd.js',
format: 'umd',
name: 'LicenseChain',
globals: {
axios: 'axios',
'crypto-js': 'CryptoJS',
jose: 'jose',
},
sourcemap: true,
},
plugins: buildPlugins({ minify: true }),
},
{
input: 'src/index.ts',
output: {
file: packageJson.types,
format: 'es',
},
plugins: [dts()],
external: [/\.css$/],
},
];