Skip to content

Instantly share code, notes, and snippets.

@jacobtoye
Created May 25, 2012 00:09
Show Gist options
  • Save jacobtoye/2785015 to your computer and use it in GitHub Desktop.
Save jacobtoye/2785015 to your computer and use it in GitHub Desktop.
Directory Structure
({
appDir: '../',
baseUrl: '../js/',
dir: '../../Website-build',
//optimize: 'none',
paths: {
'shared-libs': '../libs/shared-libs',
'map-libs': '../libs/map-libs',
'main': 'map/main'
},
modules: [
{
name: 'shared-libs'
},
{
name: 'map-libs'
},
{
name: 'main',
exclude: [
'shared-libs',
'map-libs'
]
}
]
})
/
/build
app.build.js
/js
/map
main.js (when built will contain all dependencies)
/libs
/jquery
jquery.1.7.1.js
/...(other libs here in subfolders
map-libs.js (dummy file that will contain all the compressed map libs)
shared-libs.js (dummy file that will contain all the compressed shared libs)
require.config({
priority: ['../libs/shared-libs', '../libs/map-libs', 'main'],
paths: {
//libraries
'jquery': '../../libs/jquery/jquery-1.7.1.min',
'underscore': '../../libs/underscore/underscore-min',
'backbone': '../../libs/backbone/backbone-min',
'bootstrap': '../../libs/bootstrap/bootstrap.min',
'bootstrap-datepicker': '../../libs/bootstrap/bootstrap-datepicker',
'date': '../../libs/date/date',
//map libraries
'leaflet': '../../libs/leaflet/leaflet-src',
'iconlabel': '../../libs/leaflet/plugins/Icon.Label',
'wax': '../../libs/wax/wax.leaf.min',
//require plugins
'text': '../../libs/require/text',
'use': '../../libs/require/use',
'order': '../../libs/require/order',
//jquery plugins
'color': '../../libs/jquery/plugins/jquery.color', //should we remove this, it is 16KB??
'limitmaxlength': '../../libs/jquery/plugins/jquery.limitmaxlength',
'smartresize': '../../libs/jquery/plugins/jquery.smartresize',
'autocomplete': '../../libs/jquery/plugins/jquery-ui.autocomplete.min', //temp until bootstrap typeahead supports remote datasources
'timepicker': '../../libs/jquery/plugins/jquery.timeentry'
},
use: {
underscore: {
attach: '_'
},
backbone: {
deps: ['use!underscore', 'jquery'],
attach: function (_, $) {
return Backbone;
}
},
bootstrap: {
deps: ['jquery']
},
'bootstrap-datepicker': {
deps: ['jquery', 'use!bootstrap']
},
leaflet: {
attach: 'L'
},
iconlabel: {
deps: ['use!leaflet']
},
wax: {
deps: ['use!leaflet'],
attach: function (L) {
return wax;
}
},
color: {
deps: ['jquery']
},
limitmaxlength: {
deps: ['jquery']
},
smartresize: {
deps: ['jquery']
},
autocomplete: {
deps: ['jquery']
},
timepicker: {
deps: ['jquery']
}
}
});
require([
'jquery',
'use!leaflet',
'router',
'collections/Resources',
'models/UserSettings',
'views/Application'
], function (jQuery, L, Router, Resources, UserSettings, Application) {
jQuery(/function ($) {
//...
});
});
define(["leaflet", "iconlabel", "wax"],
function () {
//Just an empty function, this is a place holder
//module that will be optimized to include the
//common depenendencies listed in this module's dependency array.
});
define([
'jquery',
'underscore',
'backbone',
'bootstrap',
'bootstrap-datepicker',
'date',
'leaflet',
'iconlabel',
'wax',
'text',
'use',
'order',
'color',
'limitmaxlength',
'smartresize',
'autocomplete',
'timepicker'
],
function () {
//Just an empty function, this is a place holder
//module that will be optimized to include the
//common depenendencies listed in this module's dependency array.
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment