/require-context

require.context for Nodejs

Primary LanguageJavaScriptMIT LicenseMIT

require.context for Nodejs

alias webpack require.context()

Install

npm install @wotermelon/require-context

Quick Start

const requireContext = require('@wotermelon/require-context')

const fileModules = requireContext('./', false, /\.js$/)

// {
//   './index.js': module
// }

API

requireContext(dir, useSubdirectories, regExp)
  • dir Which directory to find, can be an absolute path.
  • useSubdirectories Whether to traverse subdirectories recursively. Defaule is false.
  • regExp To match the file path.