forked from microsoft/azure-devops-extension-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
97 lines (95 loc) · 2.82 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/**
* Rollup configuration file for building a JavaScript SDK in different formats: ESM and AMD
*/
import typescript from "@rollup/plugin-typescript" // Compiles TypeScript to JavaScript
import del from "rollup-plugin-delete" // Deletes files and folders
import terser from "@rollup/plugin-terser" // Minifies JavaScript
import copy from "rollup-plugin-copy" // Copies files and folders
export default [
// AMD Bundle: Backward Compatibility
// Also, cleaning bin folder first and copying License and package.json to the bin folder (root of the package).
{
input: "src/SDK.ts",
external: ["tslib"], // Exclude tslib from the final bundle. It will be imported from external source at runtime.
output: {
dir: "bin",
format: "amd",
sourcemap: true,
preserveModules: true,
},
plugins: [
del({ targets: "bin/*" }),
typescript({ tsconfig: "./tsconfig.amd.json" }), // Mentioning tsconfig.amd.json file (where declaration is set to true), so d.ts files are generated.
copy({
targets: [
{ src: "package.json", dest: "bin" },
{ src: "LICENSE", dest: "bin" },
{ src: "README.md", dest: "bin" },
{ src: "SECURITY.md", dest: "bin" }
]
}),
]
},
// AMD Bundle: Minified - Generating SDK.min.js
{
input: "src/SDK.ts",
output: {
file: "bin/SDK.min.js",
format: "amd",
},
plugins: [
typescript(),
terser()
]
},
// AMD Bundle: Minified - Generating XDM.min.js
{
input: "src/XDM.ts",
output: {
file: "bin/XDM.min.js",
format: "amd",
},
plugins: [
typescript(),
terser()
]
},
// ESM Bundle
{
input: "src/SDK.ts",
output: {
dir: "bin/esm",
format: "esm",
sourcemap: true,
preserveModules: true
},
plugins: [
del({ targets: "bin/esm/*" }),
typescript({ tsconfig: "./tsconfig.esm.json" }),
]
},
// ESM Bundle: Minified - Generating SDK.min.js
{
input: "src/SDK.ts",
output: {
file: "bin/esm/SDK.min.js",
format: "esm",
},
plugins: [
typescript({ tsconfig: "./tsconfig.esm.json" }),
terser()
]
},
// ESM Bundle: Minified - Generating XDM.min.js
{
input: "src/XDM.ts",
output: {
file: "bin/esm/XDM.min.js",
format: "esm",
},
plugins: [
typescript({ tsconfig: "./tsconfig.esm.json" }),
terser()
]
}
]