forked from MaximeHeckel/design-system
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesbuild.build.js
49 lines (46 loc) · 1.07 KB
/
esbuild.build.js
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
const esbuild = require('esbuild');
const packagejson = require('./package.json');
const { globPlugin } = require('esbuild-plugin-glob');
const sharedConfig = {
loader: {
'.tsx': 'tsx',
'.ts': 'tsx',
},
outbase: './src',
bundle: true,
minify: true,
jsxFactory: 'createElement',
jsxFragment: 'Fragment',
target: ['esnext'],
logLevel: 'debug',
external: [...Object.keys(packagejson.peerDependencies || {})],
};
esbuild
.build({
...sharedConfig,
entryPoints: ['src/index.ts'],
outdir: 'dist/cjs',
format: 'cjs',
banner: {
js: "const { createElement, Fragment } = require('react');\n",
},
})
.catch(() => process.exit(1));
esbuild
.build({
...sharedConfig,
entryPoints: [
'src/index.ts',
'src/components/**/index.tsx',
'src/lib/stitches.config.ts',
'src/lib/globalStyles.ts',
],
outdir: 'dist/esm',
splitting: true,
format: 'esm',
banner: {
js: "import { createElement, Fragment } from 'react';\n",
},
plugins: [globPlugin()],
})
.catch(() => process.exit(1));