-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtsup.config.ts
More file actions
80 lines (78 loc) · 1.9 KB
/
tsup.config.ts
File metadata and controls
80 lines (78 loc) · 1.9 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
import { defineConfig } from 'tsup'
import type { Plugin } from 'esbuild'
import path from 'path'
/**
* Strips `?raw` query suffixes from import specifiers so esbuild resolves the
* underlying file and applies the text loader (configured via `loader: { '.css': 'text' }`).
*/
function rawLoader(): Plugin {
return {
name: 'raw-loader',
setup(build) {
build.onResolve({ filter: /\?raw$/ }, (args) => ({
path: path.resolve(args.resolveDir, args.path.replace(/\?raw$/, '')),
}))
},
}
}
export default defineConfig([
{
entry: ['src/index.ts', 'src/utils.ts', 'src/preload.ts'],
format: ['cjs', 'esm'],
dts: true,
splitting: false,
sourcemap: true,
clean: ['**/*', '!styles.css'],
external: ['react', 'react-dom'],
loader: { '.css': 'text' },
esbuildPlugins: [rawLoader()],
},
{
entry: { preload: 'src/preload.ts' },
format: ['iife'],
outDir: 'dist/preload',
outExtension: () => ({ js: '.js' }),
dts: false,
splitting: false,
sourcemap: false,
clean: false,
platform: 'browser',
globalName: 'DirectEditPreload',
},
{
entry: { vite: 'vite/index.ts' },
format: ['esm'],
outDir: 'dist',
outExtension: () => ({ js: '.mjs' }),
dts: false,
splitting: false,
sourcemap: true,
clean: false,
external: ['vite'],
},
{
entry: { babel: 'babel/index.cjs' },
format: ['cjs'],
outDir: 'dist',
outExtension: () => ({ js: '.cjs' }),
dts: false,
splitting: false,
sourcemap: false,
clean: false,
platform: 'node',
},
{
entry: { cli: 'src/cli.ts' },
format: ['cjs'],
outDir: 'dist',
outExtension: () => ({ js: '.cjs' }),
dts: false,
splitting: false,
sourcemap: false,
clean: false,
platform: 'node',
target: 'node18',
banner: { js: '#!/usr/bin/env node' },
noExternal: ['commander', 'prompts', 'picocolors'],
},
])