-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathtsdown.config.ts
More file actions
49 lines (44 loc) · 1.12 KB
/
tsdown.config.ts
File metadata and controls
49 lines (44 loc) · 1.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
import { globSync } from 'node:fs';
import type { UserConfig } from 'tsdown';
import { defineConfig } from 'tsdown';
type BuildMode = 'dev' | 'default';
const buildModes: BuildMode[] = ['dev', 'default'];
const entries = Object.fromEntries(
globSync('src/**/*.tailwind.ts').map((file) => {
const key = file.replace('src/', '').replace('.ts', '');
return [key, file];
})
);
const createConfig = (mode: BuildMode): UserConfig => ({
entry: entries,
platform: 'browser',
format: 'es',
sourcemap: true,
clean: true,
hash: false,
unbundle: true,
outDir: `dist/${mode}`,
define: {
__DEV__: mode === 'dev' ? 'true' : 'false',
},
dts: mode === 'dev' ? { tsgo: true, tsconfig: 'tsconfig.dts.json' } : false,
copy: [
{
from: 'src/**/*.css',
to: `dist/${mode}`,
flatten: false,
},
],
plugins: [
{
name: 'watch-css',
buildStart() {
const cssFiles = globSync('src/**/*.css');
for (const file of cssFiles) {
this.addWatchFile(file);
}
},
},
],
});
export default defineConfig(buildModes.map((mode) => createConfig(mode)));