简体   繁体   中英

optimizing a javascript file with r.js

I use 3rd party libraries which looks like the following

(function ($) {

....

})(jQuery);

I have entries for this js in my config.js

paths : {
'someLibrary' : 'path/to/someLibrary',
},

shim : {
'someLibrary' : { deps: ['jquery'] }
}

It works fine without r.js optimizer, but once I run the optimizer,
I get error, because of the jQuery is not defined in the library code.

How do I resolve this?

edit

My r.js build file has mainConfigFile set.

you may need to add jquery in the path also like

paths : {
'someLibrary' : 'path/to/someLibrary',
jquery : 'path/to/jquery'
},

shim : {
'someLibrary' : { deps: ['jquery'] }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM