javascript - How to use requirejs to load a directory recursivelly? -


how use requirejs require files on directory , subdirectories of 1 recursivelly?

for example, if have directory like:

vendor     vendor1         vendor11.js     vendor2         vendor21.js         vendor22.js         vendor23.js     vendor3         vendor31.js 

how can load entire directory vendor? using function require(['vendor/*'], mycallbackfunction)?

this function should load equivalent:

require(     ['vendor/vendor1/vendor11.js'],     require(         ['vendor/vendor2/vendor21.js'],         require(             ['vendor/vendor2/vendor22.js'],             ...and on                 ... require(                     ['vendor/vendor3/vendor31.js'],                     mycallbackfunction                 )         )     ) ); 

requirejs not provide facilities load modules according pattern. pass require has list of actual module names.

one option when build application, scan modules according pattern want , create module loads of other modules. instance, named 'vendor_all' , contain:

define(['vendor/vendor1/vendor11', 'vendor/vendor2/vendor21', ...]); 

you require(['vendor_all'], function () {...}); or put 'vendor_all' in list of dependencies of module.


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -