require-all-context

1.0.1 • Public • Published

Require All for Webpack contexts

Build Status

Usage

requireAll(context: WebpackContext, options?: Options)

interface Options {
  ext: string;
  formatKey(x: string): string;
}
const requireAll = require('require-all-context')
var stuffContext = require.context('./stuff', true, /\.js$/)
var stuff = requireAll(stuffContext)

Output

The following directory structure

/stuff
  bar.js
  foo.js
  /nested
    zap.js
    /weirdly-named-folder
      things.js

produces the following object

{ 
  bar: ..., 
  foo: ..., 
  nested: {
    zap: ...,
    weirdlyNamedFolder: {
      things: ...
    }
  } 
}

/require-all-context/

    Package Sidebar

    Install

    npm i require-all-context

    Weekly Downloads

    3

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • jonjaques