-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesbuild.config.ts
More file actions
42 lines (39 loc) · 1.15 KB
/
esbuild.config.ts
File metadata and controls
42 lines (39 loc) · 1.15 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
import { readFile } from 'node:fs/promises';
import { resolve } from 'node:path';
import { build } from 'esbuild';
import glob from 'fast-glob';
import { addDeclarations } from './esbuild-plugin-add-declarations.js';
import { addPackageJson } from './esbuild-plugin-add-package.js';
build({
sourceRoot: 'src',
entryPoints: await glob('src/cem-plugin-*/index.ts'),
// we don't mess with the default build output, but use the temp dir
outdir: 'dist',
platform: 'node',
format: 'esm',
bundle: true,
metafile: true,
minify: true,
treeShaking: true,
sourcemap: true,
logLevel: 'error',
banner: {
js: `
const require = await import('module').then($=>$.createRequire(import.meta.url));
const __filename = await import('url').then($=>$.fileURLToPath(import.meta.url));
`,
},
plugins: [
addPackageJson({
filter: /cem-plugin-.*\/index\.ts$/,
addReadme: true,
async readmeTemplate({ basePath }) {
return await readFile(resolve('src', basePath, 'README.md'), 'utf-8');
},
}),
addDeclarations({
filter: /cem-plugin-.*\/index\.ts$/,
include: ['src/typings.d.ts'],
}),
],
});