require-all-context

v1.0.1
[![Build Status](https://travis-ci.org/jonjaques/require-all-context.svg?branch=master)](https://travis-ci.org/jonjaques/require-all-context)

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: ...
    }
  } 
}
npm i require-all-context

Metadata

  • MIT
  • Whatever
  • Unknown
  • released 9/5/2017

Downloads

Maintainers