-
Notifications
You must be signed in to change notification settings - Fork 336
Expand file tree
/
Copy pathtsup.config.ts
More file actions
67 lines (63 loc) · 2.12 KB
/
tsup.config.ts
File metadata and controls
67 lines (63 loc) · 2.12 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
import { defineConfig } from 'tsup'
import { join } from 'path'
import { replace } from 'esbuild-plugin-replace'
const isStandaloneBuild = !!process.env.SATORI_STANDALONE
export default defineConfig({
entry: {
[isStandaloneBuild ? 'standalone' : 'index']: 'src/index.ts',
'jsx/index': 'src/jsx/index.ts',
'jsx/jsx-runtime': 'src/jsx/jsx-runtime.ts',
},
splitting: false,
sourcemap: true,
target: 'node16',
dts: process.env.NODE_ENV !== 'development' && {
resolve: ['twrnc', './tw-config', './types'],
},
minify: process.env.NODE_ENV !== 'development',
format: ['esm', 'cjs'],
noExternal: ['twrnc', 'emoji-regex-xs', 'yoga-layout'],
esbuildOptions(options) {
options.tsconfig = 'tsconfig.json'
options.legalComments = 'external'
},
env: isStandaloneBuild
? {
SATORI_STANDALONE: '1',
}
: {},
esbuildPlugins: [
{
name: 'optimize tailwind',
setup(build) {
// Get rid of chalk
// https://github.com/tailwindlabs/tailwindcss/blob/b8cda161dd0993083dcef1e2a03988c70be0ce93/src/util/log.js
build.onResolve({ filter: /\/log$/ }, (args) => {
if (args.importer.includes('/tailwindcss/')) {
return {
path: join(__dirname, 'src', 'vendor', 'twrnc', 'log.js'),
}
}
})
// Get rid of picocolors
// https://github.com/tailwindlabs/tailwindcss/blob/bf4494104953b13a5f326b250d7028074815e77e/src/featureFlags.js
build.onResolve({ filter: /^picocolors$/ }, () => {
return {
path: join(__dirname, 'src', 'vendor', 'twrnc', 'picocolors.js'),
}
})
// Get rid of util-deprecate/node.js
build.onResolve({ filter: /util-deprecate/ }, () => {
return {
path: join(__dirname, 'src', 'vendor', 'twrnc', 'deprecate.js'),
}
})
},
},
// We don't like `Function`.
// https://github.com/tailwindlabs/tailwindcss/blob/bf4494104953b13a5f326b250d7028074815e77e/src/util/getAllConfigs.js#L8
replace({
'preset instanceof Function': 'typeof preset === "function"',
}),
],
})