-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
36 lines (34 loc) · 860 Bytes
/
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
import esbuild from 'esbuild';
const requirePolyfill = `
import path from 'path';
import { fileURLToPath } from 'url';
import { createRequire as topLevelCreateRequire } from 'module';
const require = topLevelCreateRequire(import.meta.url);
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
`;
esbuild
.build({
entryPoints: ['src/server.js'],
bundle: true,
platform: 'node',
target: 'node16',
format: 'esm',
loader: {
'.js': 'jsx',
'.jsx': 'jsx',
},
jsxFactory: 'React.createElement',
jsxFragment: 'React.Fragment',
outfile: 'dist/server.mjs',
banner: {
js: requirePolyfill,
},
})
.then(() => {
console.info('[esbuild] 서버 빌드완료');
})
.catch((e) => {
console.info('빌드실패');
process.exit(1);
});