Reputation: 3577
main.js:
require.config({
baseUrl: 'js/',
paths: {
'd3': 'lib/d3',
'text': 'lib/text',
'jquery': 'lib/jquery',
'topojson': 'lib/topojson',
'statecodes': 'lib/statecodes',
'underscore': 'lib/underscore'
},
shim: {
'lib/bootstrap': {
deps: ['jquery']
},
'lib/backbone': {
deps: ['jquery', 'underscore'],
exports: 'Backbone'
},
'lib/wreqr': {
deps: ['lib/backbone']
},
'lib/marionette': {
deps: ['lib/wreqr'],
exports: 'Marionette'
}
}
});
var deps = [
'app',
'utils/dataserver',
'd3',
'text',
'jquery',
'topojson',
'statecodes',
'underscore',
'lib/bootstrap',
'lib/backbone',
'lib/marionette'
];
require(deps, function(app, ds) {
app.start();
ds.fetchall();
});
The config file app.build.js:
({
baseUrl: "../js",
name: 'main',
mainConfigFile: '../js/main.js',
out: "../js/build.js"
})
By running r.js -o app.build.js
I was expecting the optimizer to minify and concatenate the scripts inside path
. But all it does is minify main.js
. What am I missing?
Output of r.js -o app.build.js
:
Tracing dependencies for: main
Uglifying file: /Project/web/js/build.js
/Project/web/js/build.js
----------------
/Project/web/js/main.js
Upvotes: 0
Views: 622
Reputation: 11588
You must pass the literal array of dependencies, not the variable deps,
as the first argument to require.
Otherwise, the optimizer doesn't know what files to include.
Upvotes: 1
Reputation: 1591
r.js
will only trace through all the dependencies that it finds are needed for your application. You need to include the entry point require([], function() {});
inside main.js
, or basically the beginning require
block that should be included in the script specified in data-main
when using RequireJS regularly.
Upvotes: 0