-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtsup.config.ts
89 lines (83 loc) · 2.08 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
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
81
82
83
84
85
86
87
88
89
import { defineConfig, Options } from "tsup";
import { solidPlugin } from "esbuild-plugin-solid";
// @ts-expect-error node built-in module
import { readFileSync } from "node:fs";
const VERSION = JSON.parse(readFileSync("package.json", "utf-8")).version;
export default defineConfig(
(config) =>
[
// ESM and CJS builds published to NPM
{
entry: ["src/index.tsx"],
format: ["esm", "cjs"],
dts: true,
clean: !config.watch,
minify: false,
esbuildPlugins: [solidPlugin()],
env: {
VERSION,
},
},
// Solid-JS builds published to NPM
{
entry: ["src/index.solid.tsx"],
format: "esm",
dts: true,
clean: !config.watch,
minify: false,
esbuildOptions: () => ({
jsx: "preserve",
}),
outExtension: () => ({
js: ".jsx",
}),
env: {
VERSION,
},
},
// Global window object bundled
{
entry: ["src/index.tsx"],
format: ["iife"],
noExternal: [/(.*)/],
clean: !config.watch,
minify: true,
esbuildPlugins: [solidPlugin()],
env: {
VERSION,
},
globalName: "__docsearch_meilisearch__",
platform: "browser",
footer: {
js: "if (!'__docsearch_meilisearch__' in window) window.__docsearch_meilisearch__ = __docsearch_meilisearch__",
},
},
// ESM bundled
{
entry: ["src/index.tsx"],
format: ["esm"],
clean: !config.watch,
minify: true,
esbuildPlugins: [solidPlugin()],
noExternal: [/(.*)/],
outExtension: () => ({
js: ".bundled.esm.js",
}),
env: {
VERSION,
},
platform: "browser",
},
// CSS
{
entry: [
"src/styles/index.css",
"src/styles/variables.css",
"src/styles/button.css",
"src/styles/modal.css",
],
clean: !config.watch,
minify: false,
},
] as Options[],
);