-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathtsup.config.ts
More file actions
44 lines (41 loc) · 1.11 KB
/
tsup.config.ts
File metadata and controls
44 lines (41 loc) · 1.11 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
import { TsconfigPathsPlugin } from '@esbuild-plugins/tsconfig-paths'
import { defineConfig } from 'tsup'
import { readFileSync } from 'node:fs'
import pkg from './package.json'
const textFilePlugin = {
name: 'text-file-loader',
setup(build: any) {
// 处理 XML 文件
build.onLoad({ filter: /\.xml$/ }, async (args: any) => {
const content = readFileSync(args.path, 'utf8')
return {
contents: `export default ${JSON.stringify(content)}`,
loader: 'js',
}
})
// 处理 MD 文件
build.onLoad({ filter: /\.md$/ }, async (args: any) => {
const content = readFileSync(args.path, 'utf8')
return {
contents: `export default ${JSON.stringify(content)}`,
loader: 'js',
}
})
},
}
export default defineConfig({
entry: ['src/main.ts'],
format: ['cjs'],
outDir: 'dist',
treeshake: true,
clean: true,
sourcemap: false,
noExternal: [
...Object.keys(pkg.dependencies || {}),
],
external: ['@valibot/to-json-schema'],
esbuildPlugins: [
TsconfigPathsPlugin({ tsconfig: './tsconfig.json' }),
textFilePlugin,
],
})