diff options
author | 2022-02-06 15:05:10 -0800 | |
---|---|---|
committer | 2022-02-06 15:05:10 -0800 | |
commit | dded255306bfb1dc176178bafb4e6a8453db697a (patch) | |
tree | 97c495ca183ac7354125b0a8c4f12b9d459e4311 | |
parent | 9c5dead232ad250342f682da79bd593c60f8f45e (diff) | |
download | bun-dded255306bfb1dc176178bafb4e6a8453db697a.tar.gz bun-dded255306bfb1dc176178bafb4e6a8453db697a.tar.zst bun-dded255306bfb1dc176178bafb4e6a8453db697a.zip |
Little doc
Diffstat (limited to '')
-rw-r--r-- | README.md | 50 | ||||
-rw-r--r-- | src/bunfig.zig | 8 |
2 files changed, 49 insertions, 9 deletions
@@ -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 | diff --git a/src/bunfig.zig b/src/bunfig.zig index c22834006..46d14ff0f 100644 --- a/src/bunfig.zig +++ b/src/bunfig.zig @@ -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; - } - } } } |