-
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathtsup.config.ts
More file actions
37 lines (36 loc) · 1019 Bytes
/
tsup.config.ts
File metadata and controls
37 lines (36 loc) · 1019 Bytes
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
import { defineConfig } from 'tsup';
import { copyFileSync, existsSync } from 'fs';
import { join } from 'path';
export default defineConfig({
entry: ['src/index.tsx'],
format: ['cjs', 'esm'],
dts: true,
splitting: false,
sourcemap: true,
clean: true,
treeshake: true,
minify: false, // Let consumers minify if needed
external: ['react', 'react-dom', 'react/jsx-runtime'],
esbuildOptions(options: any) {
options.jsx = 'automatic';
},
outDir: 'dist',
outExtension({ format }: { format: string }) {
return {
js: format === 'cjs' ? '.cjs' : '.mjs',
};
},
// Don't bundle CSS - export it separately
loader: {
'.css': 'empty',
},
onSuccess: async () => {
// Copy CSS file to dist after build
const cssSource = join(process.cwd(), 'src/styles/default.css');
const cssDest = join(process.cwd(), 'dist/styles.css');
if (existsSync(cssSource)) {
copyFileSync(cssSource, cssDest);
console.log('✓ Copied styles.css to dist');
}
},
});