Answer the question
In order to leave comments, you need to log in
How to create, using webpack, an auto-assembled index.js file for easy component import?
Preamble
I have a React project, I use the components, containers folders, as the developers bequeathed, but added one more: common. The first two are for a specific project, the last one is for an emerging framework-for-itself. But that is not the crux of the matter.
Goal-setting
There is a practice where index.js is created in the containers folder with the import of all the files in the folder, so that you can then do it and be happy. Which is what I want. But! Manually adding and changing this file is another layer where you can make a mistake and catch extra minutes of debugging. Question
How to set Webpack on this?import { Comp1, Comp2 } from '../components';
I believe that you can write a crutch yourself (probably), but I look forward to all sorts of extreme situations (the component file was deleted, it remained in index.js ... and so on). In the world of npm, yarn, webpack-loaders and react-components, there is no need for excessive cycling.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question