babel-plugin-require-context-hook
Babel plugin to replicate Webpack require.context
Last updated 2 years ago by smrq .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install babel-plugin-require-context-hook 
SYNC missed versions from official npm registry.

babel-plugin-require-context-hook

Usage

babelrc:

"plugins": [
	"require-context-hook"
]

Wherever you configure babel-register (your source file, a register script, etc):

require('babel-plugin-require-context-hook/register')();

How it works

The register script babel-plugin-require-context-hook/register implements the function require.context with an extra parameter-- the directory in which the calling file resides-- and places that function on the global scope.

The Babel plugin babel-plugin-require-context-hook rewrites all calls to require.context into calls to this global function, passing in __dirname as the extra parameter.

Current Tags

  • 1.0.0                                ...           latest (2 years ago)

1 Versions

  • 1.0.0                                ...           2 years ago

Copyright 2014 - 2016 © taobao.org |