generated from thedanchez/template-solidjs-library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tsup.config.ts
34 lines (29 loc) · 1.19 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
import inlineCssModules from "esbuild-css-modules-plugin";
import { defineConfig } from "tsup";
import * as preset from "tsup-preset-solid";
const generateSolidPresetOptions = (watching: boolean): preset.PresetOptions => ({
entries: [
{
// entries with '.tsx' extension will have `solid` export condition generated
entry: "src/index.tsx",
},
],
drop_console: !watching, // remove all `console.*` calls and `debugger` statements in prod builds
cjs: false,
esbuild_plugins: [inlineCssModules()],
});
export default defineConfig((config) => {
const watching = !!config.watch;
const solidPresetOptions = generateSolidPresetOptions(watching);
const parsedOptions = preset.parsePresetOptions(solidPresetOptions, watching);
if (!watching) {
const packageFields = preset.generatePackageExports(parsedOptions);
// console.log(`\npackage.json: \n${JSON.stringify(packageFields, null, 2)}\n\n`);
/* will update ./package.json with the correct export fields */
preset.writePackageJson(packageFields);
}
const tsupOptions = preset
.generateTsupOptions(parsedOptions)
.map((tsupOption) => ({ name: "uplot-solid", ...tsupOption }));
return tsupOptions;
});