-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
35 lines (31 loc) · 891 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
const entrypoints = [
'./src/pages/login/login.island.tsx',
'./src/pages/home/home.island.ts',
'./dist/styles.css',
];
const result = await Bun.build({
entrypoints,
outdir: './dist',
root: './src',
target: 'browser',
naming: {
entry: '[dir]/[name]-[hash].[ext]',
chunk: '[name]-[hash].[ext]',
asset: '[name]-[hash].[ext]',
},
minify: true
});
if (!result.success) {
throw new AggregateError(result.logs, "Build failed");
}
const absolutePath = import.meta.path.replace('build.js', '');
const length = entrypoints.length;
const path = './dist/bundle.json';
await Bun.write(path, JSON.stringify(result.outputs.map(function (output, i) {
return {
path: output.path.replace(absolutePath, './'),
entry: length > i ? entrypoints[i] : "",
kind: output.kind,
hash: output.hash,
};
})));