-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.ts
executable file
·130 lines (126 loc) · 3.15 KB
/
rollup.config.ts
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import { OutputOptions, RollupOptions } from "rollup";
import common from "../src/main";
const output: OutputOptions[] = [
{
exports: "named",
file: "dist/package/index.js",
format: "cjs",
preferConst: true,
},
{
exports: "named",
file: "dist/package/index.mjs",
format: "esm",
preferConst: true,
},
];
const options: RollupOptions = {
external: [
"fs",
"magic-string",
"path",
"read-pkg",
"rollup-pluginutils",
"stream",
"write-pkg",
"util",
],
input: "dist/src/main.js",
output,
plugins: [
common({
// Copy assets
copyAssets: {
files: [
"changelog.md",
"license.txt",
"readme.md",
// The first path is relative to current working directory,
// the second is relative to the output directory.
["dist/tsdoc-metadata.json", "tsdoc-metadata.json"],
],
// // Overwrite files that already exists in the output directory.
// force: true,
// // Input folder (defaults to current working directory if not
// // provided)
// input: ".",
},
// // Create assets
// createAssets: {
// files: {
// // Value can be a string, an Uint8Array, an Iterable<Uint8Array>,
// // an AsyncIterable<Uint8Array>, a Readable, or a function leading to
// // any of the previously mentioned types.
// "test-1.js": "process.exit(0)",
// },
// // Overwrite files that already exists in the output directory.
// force: true,
// }
// Generate package.json
package: {
// Set content of generated package.
content: {
// Commonjs export
main: "index.js",
// ESM export
module: "index.mjs",
// Typescript export
types: "index.d.ts",
},
// Include rollup as a dependency in the generated package.
dependencies: [
"rollup",
],
// My preferred order
order: [
"name",
"version",
"description",
"license",
"main",
"module",
"types",
"files",
"keywords",
"author",
"contributors",
"repository",
"homepage",
"bugs",
"dependencies",
"optionalDependencies",
"peerDependencies",
],
// Include these fields from the original package.json.
pick: [
"author",
"bugs",
"contributors",
"description",
"homepage",
"keywords",
"license",
"name",
"repository",
"version",
],
},
// Replace text with regular expressions
replace: {
simple: {
'\\\${"(\\w+)"}': "$1",
},
// Same as above, but as a normal pattern instead.
// patterns: [
// {
// regex: /\${"(\w+)"}/g,
// replace: "$1",
// },
// ],
},
// Generate banner in emitted files.
useBanner: true,
}),
],
};
export default options;