Skip to content Skip to sidebar Skip to footer

Optimize/build Modules Under Parallel Directories Using The Same Config File In Requirejs

I have a feeling that the title just might not be explanatory :) Setup Suppose that I have the following structure: where app.js files are main bootstrapping/entry modules for the

Solution 1:

There's no built-in wildcarding configuration for RequireJS. One way or another, you'll need code to do this. I'll observe that what you're asking for here amounts to translating a wildcard into some kind of implicit iteration on the module objects, akin to what mustache.js provides for its templates. IMO, that's a fairly brittle and limited approach in this context.

Instead, I recommend generating your modules array programmatically in JavaScript right in the build config. Recall, the build config is JavaScript not just a JSON data structure. This gives you sophisticated scripting capabilities there.

I've done this kind of scripting in the build config for the requirejs-rails gem. Here's an example gist that shows what r.js would see at build time.

Post a Comment for "Optimize/build Modules Under Parallel Directories Using The Same Config File In Requirejs"