-
Notifications
You must be signed in to change notification settings - Fork 15
/
tsup.config.ts
37 lines (35 loc) · 1.06 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
import { defineConfig } from 'tsup';
import fs from 'fs';
import path from 'path';
export default defineConfig({
target: 'esnext',
clean: true,
dts: true,
entry: ['src/index.ts'],
format: 'esm',
minify: true,
treeshake: 'recommended',
esbuildPlugins: [
{
name: "markdown-as-module",
setup(build) {
build.onResolve({ filter: /\.md$/ }, (args) => {
return {
path: path.resolve(args.resolveDir, args.path),
namespace: "markdown-as-module",
};
});
build.onLoad(
{ filter: /.*/, namespace: "markdown-as-module" },
(args) => {
const contents = fs.readFileSync(args.path, "utf8");
return {
contents: `export default ${JSON.stringify(contents)}`,
loader: "ts",
};
}
);
},
}
]
});