hearsayit / HearsayRequireJSBundle

RequireJS integration for Symfony2.
130 stars 55 forks source link

Multiple bundles? #78

Open girvo opened 8 years ago

girvo commented 8 years ago

Using the r.js optimiser, is it possible to define multiple entry points? If I'm using the Assetic filter, is it smart enough to ahead-of-time compile the required entrypoint? The reason why I ask, is that different pages load different JS entrypoints, which require() their dependencies, and it'd be awesome if the r.js optimiser when used with this bundle would handle that!

girvo commented 8 years ago

Never mind, it does exactly that! Using the {%javascripts filter="?requirejs" %} block, it will use that as an entry-point.

The one thing to be aware is that it has to point to a Javascript file that looks like this:

require([
   'dependencies',
   'go',
   'here/including/your/modules'
], function() {

});

NOT a regular define() module!