2

Is there any way to automatically import recently added files into some file (let's assume index.js) whenever we create a new file?

For example:

/components
---File1.js
---File2.js
---index.js

When I create File3.js, I want it to be automatically added into index.js so within index.js it can also export automatically

// index.js

const functionToGrapAllFilesWithinFolder = () => {
    // is there any way possible?
    // I know that using fs is not possible since it is only work at Node env, not on the browser
}

// const files = functionToGrabAllFilesWithinFolder()
export default files;
  • I don't think this is possible because JS in your browser doesn't know anything about your file system. [See if this helps](https://stackoverflow.com/questions/29722270/is-it-possible-to-import-modules-from-all-files-in-a-directory-using-a-wildcard). – sallf Dec 08 '21 at 17:36
  • @Raka Pratama did you find a way to do this? It would be great – Angel May 18 '22 at 06:38

0 Answers0