-
Notifications
You must be signed in to change notification settings - Fork 1
/
tsup.config.ts
47 lines (38 loc) · 1.25 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
// tsup.config.ts
import { rm } from 'node:fs'
import { defineConfig } from 'tsup'
import * as preset from 'tsup-preset-solid'
import AutoImport from 'unplugin-auto-import/esbuild'
const preset_options: preset.PresetOptions = {
// array or single object
entries: [
{
entry: 'src/index.tsx',
server_entry: true,
},
],
// Set to `true` to remove all `console.*` calls and `debugger` statements in prod builds
drop_console: true,
// Set to `true` to generate a CommonJS build alongside ESM
cjs: false,
esbuild_plugins: [AutoImport({
imports: ['solid-js'],
dts: './auto-imports.d.ts',
})],
}
export default defineConfig((config) => {
rm('dist', { force: true, recursive: true }, () => {})
const watching = !!config.watch
const parsed_data = preset.parsePresetOptions(preset_options, watching)
if (!watching) {
const package_fields = preset.generatePackageExports(parsed_data)
console.log(`\npackage.json: \n${JSON.stringify(package_fields, null, 2)}\n\n`)
/*
will update ./package.json with the correct export fields
*/
preset.writePackageJson(package_fields)
}
const opts = preset.generateTsupOptions(parsed_data)
console.log(JSON.stringify(opts, null, 2))
return opts
})