Open History to see the last commit
1import { defineConfig } from 'tsdown'
2import solid from 'unplugin-solid/rolldown'
3import type { UserConfig } from 'tsdown'
4β
5const baseConfig: UserConfig = {
6 target: 'esnext',
7 platform: 'browser',
8 format: ['esm', 'cjs'],
9 outDir: 'build',
10 fixedExtension: false,
11}
12β
13const environment = (development: boolean) => ({
14 NODE_ENV: development ? 'development' : 'production',
15 PROD: !development,
16 DEV: development,
17 SSR: false,
18})
19β
20const compiledConfig = (
21 entry: Record<string, string>,
22 development: boolean,
23 clean: boolean,
24): UserConfig => ({
25 ...baseConfig,
26 entry,
27 clean,
28 dts: !development,
29 env: environment(development),
30 ...(development
31 ? {}
32 : {
33 minify: {
34 compress: {
35 dropConsole: true,
36 dropDebugger: true,
37 },
38 },
39 }),
40 plugins: [solid()],
41})
42β
43const jsxConfig = (
44 entry: Record<string, string>,
45 development: boolean,
46): UserConfig => ({
47 ...baseConfig,
48 entry,
49 format: 'esm',
50 clean: false,
51 dts: false,
52 env: environment(development),
53 outExtensions: () => ({ js: '.jsx' }),
54 plugins: [],
55})
56β
57export default defineConfig([
58 compiledConfig(
59 { index: 'src/index.tsx', production: 'src/production.tsx' },
60 false,
61 true,
62 ),
63 jsxConfig(
64 { index: 'src/index.tsx', production: 'src/production.tsx' },
65 false,
66 ),
67 compiledConfig({ dev: 'src/index.tsx' }, true, false),
68 jsxConfig({ dev: 'src/index.tsx' }, true),
69])