cc-hearts / unplugin-load-file

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

unplugin-load-file

unplugin-load-file is a utility library designed to resolve the configuration file loading issues in CommonJS and ECMAScript Modules (ESM) environments in Node.js.

Installation

npm install @cc-heart/unplugin-load-file

Usage

To use unplugin-load-file, you need to import the loadFile function from the library and provide the filename path to your configuration file as an argument. The loadFile function will automatically handle the differences between CommonJS and ESM environments and return the loaded configuration object.

Here's an example of how to use loadFile:

import { loadConfig } from '@cc-heart/unplugin-load-file'

const config = await loadConfig({
  filename: 'config',
  suffixList: ['ts', 'mts', 'mjs', 'js'],
  dirPath: process.cwd()
})

if you are using commonjs, use the flowing:

const { loadConfig } = require('@cc-heart/unplugin-load-file')

LICENSE

MIT

About

License:MIT License


Languages

Language:TypeScript 95.8%Language:JavaScript 4.2%