How can I optimize my multiple requirejs projects? For instance I have this structure below where I have two main.js in different locations/ folders,
build/
build.js
dev/
index.php
core/
js/
main.js
libs/
jquery.js
local/
js/
main.js
My build/build.js
({
// Where my HTML and JS is stored.
appDir: "../dev/",
// Top-level directory containing my JS:
baseUrl: "local/view/javascript/base/",
// Where to build the optimized project.
dir: "../dist",
// Define the modules to compile.
modules: [
{
name: 'main',
mainConfigFile: '../dev/local/js/main.js'
},
{
name: 'main',
mainConfigFile: '../dev/core/js/main.js'
}
]
})
It keeps failing compressing or finding the dependencies, such as,
ERROR: ENOENT, no such file or directory 'c:\wamp\websitename\dist\local\js\jquery.js
My query.js is located in core/js/libs/ - whey is it looking for it in local\js?
What have I missed?
mainappears twice in yourmodulessetting. So you are tellingr.js"please create the modulemainin../distwith such and such options and also create modulemainin../distdifferent options". How isr.jssupposed to create two different modules that should be the same file in../dist? It can't.You also cannot put
mainConfigFileinside of a module configuration just like you do. It is a top level option so if you want to have a per-module setting you need to useoverride. And setting themainConfigFiledoes not tellr.jswhat module you are in fact trying to optimize.Something like this seems to be what is needed on the basis of what you describe in the question: