Reputation: 23945
There is a similar question here but it applies to the browser. I was wondering if I could require every file in a directory when using require.js in node.
Is there a short cut or would I have to manually iterate all files in a folder and require them one by one?
Upvotes: 1
Views: 130
Reputation: 1030
The easiest thing would be to place an index.js file in the directory, which in turn requires all the files in the directory that are related to your project. Then you can require your directory, and require.js will look up all the entries in the index.js file.
Upvotes: 1