UNPKG

@hfcjoy/load-config

Version:

可拓展的支持各种格式配置文件的数据加载

58 lines 2.76 kB
{ "name": "@hfcjoy/load-config", "version": "1.0.1", "description": "可拓展的支持各种格式配置文件的数据加载", "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" }, "keywords": [ "load-config", "find-config", "search-config" ], "license": "ISC", "repository": { "type": "git", "url": "git+https://github.com/hfcjoy/load-config.git" }, "author": "", "files": [ "dist" ], "exports": { ".": { "require": "./dist/index.cjs", "import": "./dist/index.mjs", "types": "./dist/index.d.ts" } }, "main": "dist/index.js", "module": "./dist/index.mjs", "types": "./dist/index.d.ts", "bugs": { "url": "https://github.com/hfcjoy/load-config/issues" }, "homepage": "https://github.com/hfcjoy/load-config#readme", "dependencies": { "esbuild": "0.14.27" }, "devDependencies": { "@changesets/cli": "2.21.1", "@hfcjoy/eslint-config-typescript": "2.0.1", "@types/node": "17.0.21", "deepmerge": "4.2.2", "eslint": "8.10.0", "jest": "27.5.1", "joycon": "3.1.1", "json5": "2.2.0", "prettier": "2.5.1", "tsup": "5.12.1", "typescript": "4.6.2" }, "scripts": { "build": "tsup --dts-resolve", "test": "tsup && jest" }, "readme": "<p align=\"center\" style=\"font-size:55pt\">🏗️</p>\n <h3 align=\"center\">load-config</h3>\n <p align=\"center\">\n 为程序搜索并加载配置数据\n\n<center>\n\n![npm (scoped)](https://img.shields.io/npm/v/@hfcjoy/load-config) ![Libraries.io dependency status for latest release, scoped npm package](https://img.shields.io/librariesio/release/npm/@hfcjoy/load-config) ![npm type definitions](https://img.shields.io/npm/types/@hfcjoy/load-config)\n\n</center>\n\n基于 javascript 生态传统的智能默认值,`load-config`将按照一下优先级搜索配置文件:\n\n- 在 `package.json` 配置的属性值\n- `rc`文件:`.reeluprc`\n- `rc`并且是以下后缀的文件:`.json`, `.yaml`, `.yml`, `.ts`, `.js`, `.cjs`,例如:`.reeluprc.json`\n- 是以下后缀的文件:`.config.ts`、`.config.js`、`.config.cjs`\n\n# 更强大的功能\n\n- 让配置文件支持不限层级的继承,包括:从本地文件继承、或者 npm 包的方式继承;以及混合继承,例如:`json`配置文件可以继承`.ts`配置文件\n\n```json\n{\n // 本地继承\n \"$extends\": \"../config.json\",\n // npm包继承\n \"$extends\": \"@xx/reelup\",\n // 混合继承\n \"$extends\": \"../config.ts\"\n}\n```\n\n# 用法\n\n设置一个配置项的名称,`load-config`将自动搜索:\n\n```javascript\nimport { loadConfig } from '@hfcjoy/load-config'\n\nawait loadConfig('reelup')\n```\n" }