This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

@charrue/load-config
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

功能说明

支持加载配置.js.ts类型的配置文件,并提供了结果缓存的功能。

配置文件中支持使用第三方依赖。

下载

npm install @charrue/load-config

使用

// charrue.config.ts
import { defineConfig } from "@charrue/load-config";

type UserConfig = {
  name: string;
}

export default defineConfig<UserConfig>({
  name: "foo"
})
import { loadConfig } from "@charrue/load-config";

// 文件名不需要带上扩展名,该方法会自动从charrue.config.ts或charrue.config.js
// 优先加载ts文件
const { config } = loadConfig("charrue.config") // { name: "foo" }

API

const loadConfigFromFile: (configFilePath: string) => Promise<{
    config: any;
    dependencies: string[];
}>;

const loadConfig: (
		filename: string,
    options?: { cwd?: string }
) => Promise<{ config: any; dependencies: string[]; path: string; }>;

const defineConfig: <T = any>(config: T) => T;

Dependencies (3)

Dev Dependencies (23)

Package Sidebar

Install

npm i @charrue/load-config

Weekly Downloads

5

Version

0.0.5

License

MIT

Unpacked Size

33 kB

Total Files

5

Last publish

Collaborators

  • charrue