forked from ArnaudBarre/vite-plugin-react-click-to-component
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbundle.ts
executable file
·68 lines (62 loc) · 1.62 KB
/
bundle.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
#!/usr/bin/env tnode
import { rmSync, writeFileSync } from "fs";
import { execSync } from "child_process";
import { build } from "esbuild";
import * as packageJSON from "../package.json";
const dev = process.argv.includes("--dev");
rmSync("dist", { force: true, recursive: true });
Promise.all([
build({
bundle: true,
entryPoints: ["src/index.ts"],
outdir: "dist",
platform: "node",
target: "node14",
legalComments: "inline",
external: Object.keys(packageJSON.peerDependencies),
watch: dev,
}),
build({
bundle: true,
entryPoints: ["src/client.ts"],
outdir: "dist",
platform: "browser",
format: "esm",
target: "safari13",
legalComments: "inline",
watch: dev,
}),
]).then(() => {
execSync("cp LICENSE README.md dist/");
writeFileSync(
"dist/index.d.ts",
`import { PluginOption } from "vite";
export declare const reactClickToComponent: () => PluginOption;
`,
);
writeFileSync(
"dist/package.json",
JSON.stringify(
{
name: packageJSON.name,
description:
"Option+Right Click in your browser to open the source in your editor",
version: packageJSON.version,
author: "Arnaud Barré (https://github.com/ArnaudBarre)",
license: packageJSON.license,
repository: "github:ArnaudBarre/vite-plugin-react-click-to-component",
main: "index.js",
keywords: [
"vite",
"vite-plugin",
"react",
"inspector",
"click-to-component",
],
peerDependencies: packageJSON.peerDependencies,
},
null,
2,
),
);
});