-
Notifications
You must be signed in to change notification settings - Fork 356
Expand file tree
/
Copy pathtsup.config.ts
More file actions
68 lines (64 loc) · 2.29 KB
/
Copy pathtsup.config.ts
File metadata and controls
68 lines (64 loc) · 2.29 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
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'
},
// Always replace this flag at build time. Leaving it unresolved in the
// default build makes the browser bundle access the Node-only `process`
// global while selecting the Yoga loader.
env: {
SATORI_STANDALONE: isStandaloneBuild ? '1' : '0',
},
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"',
}),
],
})