@cc-heart/unplugin-load-file
v1.0.1
Published
load configuration files from different operating environments
Downloads
3
Readme
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')