hearsayit / HearsayRequireJSBundle

RequireJS integration for Symfony2.
130 stars 55 forks source link

enable JS File loading from public folders to increase performance in development #77

Open lautr opened 10 years ago

lautr commented 10 years ago

We are having the Issue that we use a lot of modules ( 20+ per page ), and since all of them in dev mode are loaded via PHP, this slows development ( especially if you develop in Vagrant like we do ) down considerably, we ether run in timeouts or have to wait forever before all modules are loaded.

As a Solution i would like to be able to load the modules directly form their public folders bypassing PHP / Symfony2 like:

require([
    '/bundles/acmebundle/js/module1.js',
    '/bundles/acmebundle/js/module2.js'
],
    function (module1, module2) {
        'use strict';
        // code
    }
);

This works in dev but breaks on assetic dump.

girvo commented 9 years ago

@lautr The way I achieved this was setting each bundle up as a path in the config for requirejs; So: CCESiteBundle/some/js/here that points to CCE/SiteBundle/Resources/public/js -- combining that with php app/console assetic:watch meant that in dev mode it was loading it correctly from the public folder. It's quite fast, too, and works perfectly with the r.js optimizer in production mode.