1.0.1 • Published 7 years ago

require-all-context v1.0.1

Weekly downloads
3
License
MIT
Repository
-
Last release
7 years ago

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: ...
    }
  } 
}