jrburke/requirejs — Issue #185: paths options from mainConfigFile not used when optimising with r.js
Author: KidkArolis
Created: 2012-02-18 19:51:32+00:00
State: open

Hi,

not sure whether I'm missing something or I've found a bug.

I started using mainConfigFile option in my build file, i.e.

mainConfigFile: "myapp/boot.js",

boot.js file contains paths option

require.config({
...
paths: {
"text": "vendors/requirejs/text",
"tpl": "vendors/requirejs/tpl",
"use": "vendors/requirejs/use",
"jquery": "vendors/jquery",
"app": "somewhere/app"
},
...
});

When I build with r.js, however, the paths from boot.js are not used. The build only succeeds if I copy this paths configuration into the myapp.build.js file

On a sidenote, every time I try to setup an r.js build, all the path resolution is soo confusing (appDir, baseUrl, dir, etc...)
It might be helpful to have some recommended way of doing things with sensible defaults for everything. I'm afraid people might get discouraged by AMD when they struggle to understand how to use the optimiser. So it would be nice to simplify the process.
For example, I used to have baseUrl in by boot.js file, but when using mainConfigFile option the baseUrl was interfering with the build. So now I'm setting baseUrl right before injecting the script, i.e.

or for development

and I keep the rest of the configuration in the boot.js file. I thought the baseUrl option from the build file would take priority From docs: "The precedence for config: command line, build profile, mainConfigFile. In other words, the mainConfigFile configuration has the lowest priority."

I should probably split this issue into 3 :]