-
Notifications
You must be signed in to change notification settings - Fork 192
/
tsup.config.ts
59 lines (55 loc) · 1.78 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// biome-ignore lint/correctness/noNodejsModules: We need this for development only
import { spawnSync } from 'node:child_process';
import { defineConfig } from 'tsup';
export default defineConfig({
entry: ['src/**/index.ts', 'src/**/theme.ts', 'src/**/styles.css'],
ignoreWatch: ['**/*.test.ts', '**/*.test.tsx', '**/*.stories.tsx'],
// TODO: update this based on environment, once we switch to tsup for builds
watch: ['src/**/*.{ts,tsx}'],
format: 'esm',
minify: false, // Disable minification during development
splitting: true, // Enable code splitting to properly handle React contexts
esbuildOptions(options) {
options.jsx = 'automatic';
options.jsxImportSource = 'react';
},
sourcemap: true,
outDir: 'playground/nextjs-app-router/onchainkit/esm',
dts: false,
clean: false,
silent: true, // Flip this to false to see tsup output in the terminal, including performance logs
inject: ['react-shim.js'],
// Generate declaration files separately to improve performance in development
async onSuccess() {
console.log('⚡ Rebuilt onchainkit.');
spawnSync(
'tsc',
[
'--emitDeclarationOnly',
'--declaration',
'--outDir',
'playground/nextjs-app-router/onchainkit/esm',
'--rootDir',
'src',
'src/index.ts',
'src/*.ts',
'src/**/index.ts',
'src/**/theme.ts',
'--incremental',
'--tsBuildInfoFile',
'playground/nextjs-app-router/onchainkit/esm/tsbuildinfo.json',
'--jsx',
'react-jsx',
],
{
shell: true,
},
);
// Copy tailwind styles
spawnSync('cp', [
'src/styles.css',
'playground/nextjs-app-router/onchainkit/src/styles.css',
]);
console.log('Declaration files generated.');
},
});