RequireJS Config whole directory mapping

Is it possible to map the entire directory node_modules, for example, src/lib/to the require configuration?

Project example:

project/  
project/node_modules  
project/src/  
project/src/lib/
+4
source share
1 answer

In RequireJS you can really customize pathswhich points to a folder. And you can call your path what you want. For example, if you have a folder with a name node_modules, and you have some libraries there, including jquery, you can configure the path, for example

require.config({
  paths: {
    'lib' : '/path_to_node_module_folder' 
  }
}); 

and later in your module jquery may be required, for example

define(['lib/jquery'], function($){ 
     .... 
});
+5
source

All Articles