Reputation: 6849
I am using RequireJS in a large application. I also make use of the optimization tool to optimize/minify my code.
I have my data-main file, Main.js. In this file, I define a set of shims:
require.config({
baseUrl: "js",
shim: {
"libs/shimmedLibrary": {
deps: ["libs/blah"],
exports: "shimmedLibrary"
}
}
});
In addition, I also have my buildconfig.js file, which defines the optimization parameters:
({
baseUrl: "../js",
shim: {
"libs/shimmedLibrary": {
deps: ["libs/blah"],
exports: "shimmedLibrary"
}
},
include: ["requireLib"],
name: "js/Main",
out: "../bin/js/Main-built.js",
optimize: "none"
})
Looking at these two configurations, one can see that the shim
object is identical in both files. This creates a bit of a headache because if I ever have to add in a shim
object, I have to MAKE SURE that I add the shim reference in both configuration files. In reality, my shim object actually contains about a dozen shims, so this makes maintenance a bit of a pain.
Is there any way for me to create a single, shared reference to my shim
object such that both my data-main Main.js file, and my optimization buildconfig.js file can both re-use that same reference?
Upvotes: 0
Views: 26
Reputation: 151380
Use the mainConfigFile
option in your build config so that it points to the file that contains your runtime configuration:
mainConfigFile: "js/Main.js"
Upvotes: 1