forked from MikhailMalinin-iOSDeveloper/react-native-copilot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tsup.config.ts
36 lines (34 loc) · 1.02 KB
/
tsup.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
import { defineConfig } from "tsup";
import fs from "fs/promises";
import path from "path";
export default defineConfig({
entry: ["src/index.ts"],
format: "cjs",
sourcemap: true,
dts: true,
external: ["react", "react-native", "react-native-svg"],
platform: "neutral",
async onSuccess() {
if (process.env.NODE_ENV === "development") {
const exampleOutputPath = path.resolve(
"./example/node_modules/react-native-copilot"
);
const exampleOutputNodeModulesPath = path.resolve(
exampleOutputPath,
"node_modules"
);
await Promise.all(
["dist/index.js", "dist/index.d.ts"].map(async (file) => {
const outputPath = path.resolve(exampleOutputPath, file);
console.log("Copying file: ", file, "to ->", outputPath);
await fs.copyFile(file, outputPath);
})
);
await fs.rm(exampleOutputNodeModulesPath, {
recursive: true,
force: true,
});
console.log("Copied files to example project");
}
},
});