@cc-heart/unplugin-load-file
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

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

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

    Package Sidebar

    Install

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

    Weekly Downloads

    0

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    27 kB

    Total Files

    26

    Last publish

    Collaborators

    • cc-heart