-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
68 lines (62 loc) · 2.06 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
68
// @ts-check
import { readFileSync } from 'node:fs';
import nodeResolve from "@rollup/plugin-node-resolve";
import typescript from "@rollup/plugin-typescript";
import terser from "@rollup/plugin-terser";
import filesize from "rollup-plugin-filesize";
import dts from "rollup-plugin-dts";
const pkg = JSON.parse(readFileSync(new URL('./package.json', import.meta.url)).toString());
function makeUmd({ input, output, minify }) {
return {
input,
output: {
file: output,
name: "WebSdk",
format: "umd",
indent: true,
extend: true,
banner: `// Package: ${pkg.name}\n// Homepage: ${pkg.homepage}\n// Version: v${pkg.version}\n`,
},
plugins: [
nodeResolve(),
typescript({ outDir: "dist/umd", declaration: false }),
minify ? terser() : [],
minify ? filesize({ showBeforeSizes: "build", showGzippedSize: true }) : [],
],
};
}
function makeEs({ input, output }) {
return {
input,
output: {
file: output,
name: "WebSdk",
format: "es",
},
plugins: [
nodeResolve(),
typescript({ outDir: "dist", declarationDir: "dist/types", declaration: true }),
],
};
}
function makeDts({ input, output }) {
return {
input: "dist/types/index.d.ts",
output: {
file: "dist/index.d.ts",
format: "es",
},
plugins: [
// nodeResolve(),
// typescript({ outDir: "dist", declarationDir: "dist/types", declaration: true }),
dts(),
],
};
}
const scrFromTs = "src/index.ts";
export default [
makeUmd({ input: scrFromTs, output: `dist/umd/websdk.client.min.js`, minify: true }),
makeUmd({ input: scrFromTs, output: `dist/umd/websdk.client.js`, minify: false }),
makeEs({ input: scrFromTs, output: `dist/index.js` }),
// makeDts({ input: scrFromTs, output: `dist/index.js` }),
];