Skip to content

v0.1.0

Choose a tag to compare

@Colourlessglow Colourlessglow released this 09 Jun 15:28
· 49 commits to main since this release

v0.1.0

🚨 破坏性改动

  • ⚠️ 重构整体架构,修改为 类似 unocss 需要 core + presets 形式组合 (7e94f0d)

配置文件加载工具

API 设计参考自 antfu/unconfig

esconf 在使用时更像 unocss 需要 core + presets 形式组合

esconf/preset-mini 最小预设内置解析器一览

  • .mts .ts 基于 importx 导入
  • .mjs .js 基于 原生 import('id') 导入
  • .json .jsonc .json5 .yaml .yml .toml 基于 confbox 导入

注意: 预设 js,ts 解析只包含 es module 的解析

npm version
npm downloads
bundle size
license

安装

# ✨ Auto-detect
npx nypm install esconf

# npm
npm install esconf

# yarn
yarn add esconf

# pnpm
pnpm install esconf

# bun
bun install esconf

简单使用

import { loadConfig,presetMini } from 'esconf'
import { tsParser } from 'esconf/preset-mini'

const config = await loadConfig({
    presets:[
      presetMini({
        // 配置如下会解析 vite.config.{mjs,js,ts,mts} vite.{toml,....}
        name:'vite',
        configName:'config',
        // 设置 ts 文件解析规则
        ts:{
          loader:'tsx'
        },
        // 关闭js 文件解析
        js: false,
        // ....
      })
      ],
    // 数组越靠前配置文件的优先级越高
    // layers 的优先级比 presets 高
    layers: [
      {
        // load from vrx.config.{mts,ts}
        files: ['vrx.config'],
        extensions: ['mts', 'ts'],
        parser: tsParser(),
      },
    ],
    // 配置默认值
    default: { defaultValue: 'value' },
    cwd: process.cwd(),
  })

鸣谢

贡献者

Published under the MIT license.
Made by @Colourlessglow and community 💛






🤖 auto updated with automd