forked from yydfys/CatPawOpen
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathesbuild.js
More file actions
28 lines (26 loc) · 673 Bytes
/
esbuild.js
File metadata and controls
28 lines (26 loc) · 673 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
import * as esbuild from 'esbuild';
import fs from 'fs';
import { createHash } from 'crypto';
esbuild.build({
entryPoints: ['src/index.js'],
outfile: 'dist/index.js',
bundle: true,
minify: true,
write: true,
format: 'cjs',
platform: 'node',
target: 'node18',
sourcemap: true,
plugins: [genMd5()],
});
function genMd5() {
return {
name: 'gen-output-file-md5',
setup(build) {
build.onEnd(async (_) => {
const md5 = createHash('md5').update(fs.readFileSync('dist/index.js')).digest('hex');
fs.writeFileSync('dist/index.js.md5', md5);
});
},
};
}