require-all-context
v1.0.1
Published
[![Build Status](https://travis-ci.org/jonjaques/require-all-context.svg?branch=master)](https://travis-ci.org/jonjaques/require-all-context)
Downloads
1
Readme
Require All for Webpack contexts
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: ...
}
}
}