-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesbuild.graph.mjs
More file actions
39 lines (35 loc) · 1016 Bytes
/
Copy pathesbuild.graph.mjs
File metadata and controls
39 lines (35 loc) · 1016 Bytes
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
/**
* esbuild configuration for graph React bundle
*
* Bundles ReactFlow with React loaded from CDN globals.
*/
import * as esbuild from 'esbuild';
const isWatch = process.argv.includes('--watch');
const config = {
entryPoints: ['src/graph/index.jsx'],
bundle: true,
outfile: 'public/js/graph-bundle.js',
format: 'iife',
globalName: 'InfraGraph',
minify: !isWatch,
sourcemap: isWatch,
loader: { '.jsx': 'jsx' },
jsx: 'automatic',
jsxImportSource: 'react',
// Map React imports to CDN globals
alias: {
'react': './src/graph/react-shim.js',
'react-dom': './src/graph/react-shim.js',
'react/jsx-runtime': './src/graph/react-shim.js',
'react/jsx-dev-runtime': './src/graph/react-shim.js',
'react-dom/client': './src/graph/react-shim.js',
},
};
if (isWatch) {
const ctx = await esbuild.context(config);
await ctx.watch();
console.log('Watching for changes...');
} else {
const result = await esbuild.build(config);
console.log('Build complete:', result);
}