简体   繁体   中英

Switch between r.js optimized file and requirejs script loading

I removed requirejs.config() from main.js in order to use r.js optimizer. Exported file works like a charm but now main.js will not parse the config.

I'm looking for a dummy way (eg uncommenting script tag) to switch between r.js optimized file and requirejs script loading. How can i achieve this?

Inside your main.js you can just require the config.js file before requiring any other dependencies. Basically you just wrap everything inside main.js with a require call:

require(['config'], function(){
  // The start of your old main.js file.
  require(['foo', 'bar', 'baz'], function(foo, bar, baz){
    // Do stuff with foo, bar, and baz
  });
});

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