-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0eb1c64
commit fdccec9
Showing
2 changed files
with
64 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { parseArgs } from "util"; | ||
|
||
const options = parseArgs({ | ||
args: Bun.argv, | ||
strict: true, | ||
allowPositionals: true, | ||
|
||
options: { | ||
entrypoint: { | ||
type: "string", | ||
}, | ||
|
||
inputPath: { | ||
type: "string", | ||
}, | ||
|
||
outputPath: { | ||
type: "string", | ||
}, | ||
|
||
sourcemaps: { | ||
type: "boolean", | ||
}, | ||
|
||
minify: { | ||
type: "boolean", | ||
}, | ||
}, | ||
}).values; | ||
|
||
const result = await Bun.build({ | ||
entrypoints: [options.entrypoint], | ||
publicPath: options.outputPath, | ||
outdir: options.outputPath, | ||
root: options.inputPath, | ||
minify: options.minify, | ||
|
||
sourcemap: options.sourcemaps ? "external" : "none", | ||
|
||
naming: { | ||
entry: '[dir]/[name].[ext]', | ||
chunk: "chunks/[name]-[hash].[ext]", // Not in use without --splitting | ||
asset: "assets/[name]-[hash].[ext]", // Not in use without --splitting | ||
}, | ||
|
||
target: "browser", | ||
format: "esm", | ||
}); | ||
|
||
if (!result.success) { | ||
console.error("Build failed"); | ||
for (const message of result.logs) { | ||
console.error(message); | ||
} | ||
process.exit(1); // Exit with an error code | ||
} |