Require.js: path optimization require.config

I want to optimize my javascript application using optim.js optimizer, but now I am wondering if it is also possible to include require.config paths as well as javascript modules in one file. In fact, after running r.js, I would like to get one last javascript file, which is main-built_v_0_1.js, including all paths + other js files.

Here you have the main.js file:

require.config({ paths : { // Backbone libs jquery : '../lib/jquery/jquery-1.7.1.min', underscore : '../lib/underscore/underscore-min', backbone : '../lib/backbone/backbone', text : '../lib/require/text', // JQGrid jgqridi18n : '../lib/jqgrid/js/i18n/grid.locale-en', jqgrid : '../lib/jqgrid/jquery.jqGrid.min', // Templates root directory templates : '../templates' } }); 

Then I have my backbone.js files which are app.js, router1.js, model1.js, view1.js, etc ...

Has anyone ever done this before? If possible, how can you require .js then allow these aliases distributed throughout the application?

+4
source share
1 answer

The assembly also does not automatically read the config from the main.js file. It is possible to do this, mainConfigFile, see mainConfigFile link

+1
source

Source: https://habr.com/ru/post/1403042/


All Articles