-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.mjs
More file actions
34 lines (29 loc) · 950 Bytes
/
build.mjs
File metadata and controls
34 lines (29 loc) · 950 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
import * as esbuild from 'esbuild';
import { readFileSync, writeFileSync, mkdirSync, existsSync, cpSync } from 'fs';
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const outDir = join(__dirname, 'build', 'admin');
if (!existsSync(outDir)) {
mkdirSync(outDir, { recursive: true });
}
await esbuild.build({
entryPoints: [join(__dirname, 'src', 'admin', 'index.tsx')],
bundle: true,
minify: true,
outfile: join(outDir, 'index.js'),
format: 'iife',
define: {
'process.env.NODE_ENV': '"production"',
},
jsx: 'automatic',
loader: {
'.tsx': 'tsx',
'.ts': 'ts',
'.css': 'css',
},
external: [],
logLevel: 'info',
});
writeFileSync(join(outDir, 'asset-manifest.json'), JSON.stringify({ version: '1.0.0', builtAt: new Date().toISOString() }, null, 2));
console.log('Build complete!');