Aug 19, 2017
0
Level 2
Importing all modules from folder doesnt work.(webpack.context)
I have multiply react jsx files inside a folder and i would like to use webpack.context to import them all at once.But it doesnt work.
Importing Code(modal_manager.jsx):
function importAll (r) {
console.log(r) // ['./my_modal.jsx']
r.keys().forEach(r);
}
// import all modals from folder
importAll(require.context("./", true, /^.\/(?!modal_manager).*\.jsx$/));
//trying to use class throws an error
console.log(MyModal)
Importing File(my_modal.jsx):
export default class MyModal{}
File Structure: Folder |-- modal_manager.jsx |-- my_modal.jsx
Why this doesnt work?its exactly like in the documentation.
Please or to participate in this conversation.