Created
January 18, 2019 11:59
-
-
Save jaksm/7f0824d67314705b5d8c023b699f3c44 to your computer and use it in GitHub Desktop.
Bulk import and export folder contents
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var imports = {}; | |
function importAll(r) { | |
r.keys().forEach(key => { | |
const module = r(key); | |
const name = key.split("./")[1].split(".")[0]; | |
imports[name] = module.default; | |
}); | |
} | |
importAll(require.context("./", true, /\.jsx$/)); | |
module.exports = imports; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
make src/.env file with contents: NODE_PATH=src, and you can do import { ComponentName } from "components" anywhere in your project