All Projects → antfu → unconfig

antfu / unconfig

Licence: MIT license
A universal solution for loading configurations.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to unconfig

read-env
🔧 Transform environment variables into JSON object with sanitized values.
Stars: ✭ 60 (-85.54%)
Mutual labels:  config
AbbasAtaei
Config files for my GitHub profile.
Stars: ✭ 47 (-88.67%)
Mutual labels:  config
bundle
An online tool to quickly bundle & minify your projects, while viewing the compressed gzip/brotli bundle size, all running locally on your browser.
Stars: ✭ 475 (+14.46%)
Mutual labels:  esbuild
rc-config-loader
Load config from .{product}rc.{json,yml,js} file
Stars: ✭ 46 (-88.92%)
Mutual labels:  config
scheriff
Schema Sheriff: yet another Kubernetes manifests validation tool
Stars: ✭ 15 (-96.39%)
Mutual labels:  config
lime
Simple standalone Zsh theme
Stars: ✭ 15 (-96.39%)
Mutual labels:  config
intuit-spring-cloud-config-inspector
Inspection of Spring Cloud Config properties made easy using React
Stars: ✭ 18 (-95.66%)
Mutual labels:  config
stumpwm-config
My configuration files for StumpWM
Stars: ✭ 62 (-85.06%)
Mutual labels:  config
docker-flask-example
A production ready example Flask app that's using Docker and Docker Compose.
Stars: ✭ 311 (-25.06%)
Mutual labels:  esbuild
lightning-hydra-template
PyTorch Lightning + Hydra. A very user-friendly template for rapid and reproducible ML experimentation with best practices. ⚡🔥⚡
Stars: ✭ 1,905 (+359.04%)
Mutual labels:  config
parse-git-config
Parse `.git/config` into a JavaScript object. sync or async.
Stars: ✭ 55 (-86.75%)
Mutual labels:  config
hammer
Build Tool for Browser and Node Applications
Stars: ✭ 226 (-45.54%)
Mutual labels:  esbuild
logstash-config
logstash-config provides a parser and abstract syntax tree (AST) for the Logstash config format, written in Go
Stars: ✭ 26 (-93.73%)
Mutual labels:  config
cdk-esbuild
CDK constructs for esbuild, an extremely fast JavaScript bundler
Stars: ✭ 44 (-89.4%)
Mutual labels:  esbuild
DYNAMICMORTAL
Config files for my GitHub profile.
Stars: ✭ 19 (-95.42%)
Mutual labels:  config
tailwind-layouts
Collection of Tailwind Layouts
Stars: ✭ 53 (-87.23%)
Mutual labels:  esbuild
qtile-config
My qtile config
Stars: ✭ 47 (-88.67%)
Mutual labels:  config
d-l-l
Simplified DLL config creator & handler
Stars: ✭ 27 (-93.49%)
Mutual labels:  config
superconfig
Access environment variables. Also includes presence validation, type coercion and default values.
Stars: ✭ 33 (-92.05%)
Mutual labels:  config
Enderfga
Undergraduate period academic garbage
Stars: ✭ 49 (-88.19%)
Mutual labels:  config

unconfig

NPM version

A universal solution for loading configurations.

Why?

Configuration is hard, especially when you want to build an ecosystem of your tools.

You want your tools to be general and easy to use, you allow your config to be defined in a custom field of package.json.

You want your tools to be easy to integrate, you allow the configs to be defined in other tools' configurations like vite.config.js or webpack.config.js.

You want the configs to be agnostic and probably need to be load by IDE, you create new config files like .myconfigrc.

You want the configs to also be flexible and dynamic, you make your config files a JavaScript file, like my.config.js.

Then you want users to be able to use ESM and TypeScript, you also make your config accepting .ts or .mjs.

So users' project root end up with a lot of config files like .npmrc, rollup.config.js, .eslintrc, tsconfig.json, jest.config.js, postcss.config.js, nuxt.config.js, vite.config.cjs, windi.config.ts, etc. And each of them use different syntax, in JSON, in CJS, in ESM, in TypeScript, in INI, in TOML...

unconfig can't solve this fragmentation entirely, but it's trying to make loading them easier for tool authors.

Usage

npm i unconfig

For example, to load config for my.config:

import { loadConfig } from 'unconfig'

const { config, sources } = await loadConfig({
  sources: [
    // load from `my.config.xx`
    {
      files: 'my.config',
      // default extensions
      extensions: ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs', 'json', ''],
    },
    // load `my` field in `package.json` if no above config files found
    {
      files: 'package.json',
      extensions: [],
      rewrite(config) {
        return config?.my
      },
    },
    // load inline config from `vite.config`
    {
      files: 'vite.config',
      async rewrite(config) {
        const config = await (typeof config === 'function' ? config() : config)
        return config?.my
      },
    },
    // ...
  ],
  // if false, the only the first matched will be loaded
  // if true, all matched will be loaded and deep merged
  merge: false,
})

unconfig supports loading ts, mjs, js, json by default.

Sponsors

License

MIT License © 2021 Anthony Fu

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].