Вопрос

Is it possible to map a whole directory the node_modules directory for example to src/lib/ in the require config?

Sample Project:

project/  
project/node_modules  
project/src/  
project/src/lib/
Это было полезно?

Решение

In RequireJS you actually can configure paths that points to a folder. And, you can name your path whatever you want. For example, if you have a folder named node_modules and you have some libs in there including jquery, you can configure a path like

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

and later in your module you can require jquery like

define(['lib/jquery'], function($){ 
     .... 
});
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top