-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathcli.rollup.config.ts
49 lines (45 loc) · 1.24 KB
/
cli.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
import typescript from "@rollup/plugin-typescript";
import commonjs from "@rollup/plugin-commonjs";
import resolve from "@rollup/plugin-node-resolve";
import json from "@rollup/plugin-json";
import MagicString from "magic-string";
import pkg from "./package.json"
const destination = "dist/cli.js";
const shebang = "#!/usr/bin/env node\n\n";
export default {
input: "src/cli.ts",
output: [
{
file: destination,
format: "cjs",
exports: "none"
},
],
external: [
...Object.keys(pkg.peerDependencies || {}),
],
plugins: [
typescript(),
commonjs(),
{
name: 'shebang',
renderChunk(code, _chunk, { file, sourcemap }) {
if (file !== destination) {
return null;
}
const s = new MagicString(code);
s.prepend(shebang);
if (sourcemap) {
return {
code: s.toString(),
map: s.generateMap({ hires: true }),
};
} else {
return s.toString();
}
},
},
resolve(),
json(),
],
}