![Social Card of this repo](https://github.com/stacksjs/bun-config/blob/main/.github/art/cover.png?raw=true)
![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)
Features
- Smart configuration loader
- Lightweight & zero-dependency
- Fully typed
Install
bun install -d bun-config
Get Started
If you are building any sort of Bun project, you can use the loadConfig
function to load your configuration.
import type { Config } from 'bun-config'
import { loadConfig } from 'bun-config'
interface MyLibraryConfig {
port: number
host: string
}
const options: Config<MyLibraryConfig> = {
name: 'my-app',
cwd: './',
defaults: {
port: 3000,
host: 'localhost',
},
}
const resolvedConfig = await loadConfig(options)
console.log(resolvedConfig)
[!TIP]
If your process.cwd() includes a $name.config.{ts,js,mjs,cjs}
file, it will be loaded and merged with the defaults, with file config file values taking precedence.
Testing
bun test
Changelog
Please see our releases page for more information on what has changed recently.
Contributing
Please review the Contributing Guide for details.
For help, discussion about best practices, or any other conversation that would benefit from being searchable:
Discussions on GitHub
For casual chit-chat with others using this package:
Join the Stacks Discord Server
Postcardware
Two things are true: Stacks OSS will always stay open-source, and we do love to receive postcards from wherever Stacks is used! 🌍 We also publish them on our website. And thank you, Spatie
Our address: Stacks.js, 12665 Village Ln #2306, Playa Vista, CA 90094
We would like to extend our thanks to the following sponsors for funding Stacks development. If you are interested in becoming a sponsor, please reach out to us.
Credits
License
The MIT License (MIT). Please see LICENSE for more information.
Made with 💙