mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
Little doc
This commit is contained in:
50
README.md
50
README.md
@@ -304,7 +304,54 @@ Longer-term, bun intends to replace Node.js, Webpack, Babel, and PostCSS (in pro
|
||||
|
||||
### bunfig.toml
|
||||
|
||||
TODO: document this
|
||||
bunfig.toml is bun's configuration file.
|
||||
|
||||
It lets you load configuration from a file instead of passing flags to the CLI each time. The config file is loaded before CLI arguments are parsed, which means CLI arguments can override them.
|
||||
|
||||
Here is an example:
|
||||
|
||||
```toml
|
||||
# Set a default framework to use
|
||||
# By default, bun will look for an npm package like `bun-framework-${framework}`, followed by `${framework}`
|
||||
framework = "next"
|
||||
logLevel = "debug"
|
||||
|
||||
# publicDir = "public"
|
||||
# external = ["jquery"]
|
||||
|
||||
[macros]
|
||||
# Remap any import like this:
|
||||
# import {graphql} from 'react-relay';
|
||||
# To:
|
||||
# import {graphql} from 'macro:bun-macro-relay';
|
||||
react-relay = { "graphql" = "bun-macro-relay" }
|
||||
|
||||
[bundle]
|
||||
saveTo = "node_modules.bun"
|
||||
# Don't need this if `framework` is set, but showing it here as an example anyway
|
||||
entryPoints = ["./app/index.ts"]
|
||||
|
||||
[bundle.packages]
|
||||
# If you're bundling packages that do not actually live in a `node_modules` folder or do not have the full package name in the file path, you can pass this to bundle them anyway
|
||||
"@bigapp/design-system" = true
|
||||
|
||||
[dev]
|
||||
# Change the default port from 3000 to 5000
|
||||
port = 5000
|
||||
|
||||
[define]
|
||||
# Replace any usage of "process.env.bagel" with the string `lox`.
|
||||
# The values are parsed as JSON, except single-quoted strings are supported and `'undefined'` becomes `undefined` in JS.
|
||||
# This will probably change in a future release to be just regular TOML instead. It is a holdover from the CLI argument parsing.
|
||||
"process.env.bagel" = "'lox'"
|
||||
|
||||
[loaders]
|
||||
# When loading a .bagel file, run the JS parser
|
||||
".bagel" = "js"
|
||||
|
||||
```
|
||||
|
||||
TODO: list each property name
|
||||
|
||||
### Loaders
|
||||
|
||||
@@ -322,6 +369,7 @@ Currently, bun implements the following loaders:
|
||||
| .cjs | JavaScript | .js |
|
||||
| .mts | TypeScript | .js |
|
||||
| .cts | TypeScript | .js |
|
||||
| .toml | TOML | .js |
|
||||
| .css | CSS | .css |
|
||||
| .env | Env | N/A |
|
||||
| .\* | file | string |
|
||||
|
||||
@@ -96,14 +96,6 @@ pub const Bunfig = struct {
|
||||
this.bunfig.port = 3000;
|
||||
}
|
||||
}
|
||||
|
||||
if (expr.get("port")) |port| {
|
||||
try this.expect(port, .e_number);
|
||||
this.bunfig.port = port.data.e_number.toU16();
|
||||
if (this.bunfig.port.? == 0) {
|
||||
this.bunfig.port = 3000;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user