forked from microsoft/BotFramework-WebChat
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.js
More file actions
48 lines (41 loc) · 1.21 KB
/
build.js
File metadata and controls
48 lines (41 loc) · 1.21 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
/// <reference types="node" />
/* eslint-env node */
/* eslint-disable no-magic-numbers */
/* eslint-disable require-unicode-regexp */
import * as esbuild from 'esbuild';
(async () => {
/** @type { import('esbuild').BuildOptions } */
const config = {
bundle: true,
chunkNames: 'react-dom/[name]-[hash]',
entryPoints: {
'react-dom': './src/index.ts',
'react-dom/client': './src/client.ts'
},
format: 'esm',
outdir: './dist/',
platform: 'browser',
splitting: true,
sourcemap: true,
/** @type { import('esbuild').Plugin[] } */
plugins: [
{
name: 'require-react',
setup(build) {
build.onResolve({ filter: /^react$/ }, args =>
args.kind === 'require-call' ? { path: 'react', namespace: 'stub' } : { external: true, path: args.path }
);
build.onLoad({ filter: /^react$/, namespace: 'stub' }, () => ({
contents: "export * from 'react'; export { default } from 'react';"
}));
}
}
]
};
if (process.argv[2] === '--watch') {
const context = await esbuild.context(config);
await context.watch({ delay: 200 });
} else {
await esbuild.build(config);
}
})();