Skip to content

Instantly share code, notes, and snippets.

@stream7
Created April 10, 2013 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stream7/5355821 to your computer and use it in GitHub Desktop.
Save stream7/5355821 to your computer and use it in GitHub Desktop.
main.js
require.config({
paths: {
jquery: '../components/jquery/jquery',
backbone: '../components/backbone/backbone',
underscore: '../components/underscore/underscore',
handlebars: '../components/handlebars/handlebars',
cookie: 'vendor/jquery.cookie',
routefilter: 'vendor/backbone.routefilter',
text: '../components/requirejs-text/text'
},
shim: {
backbone: {
deps: ['jquery', 'underscore'],
exports: 'Backbone'
},
underscore: {
exports: '_'
},
handlebars: {
exports: 'Handlebars'
},
cookie: {
deps: ['jquery']
},
routefilter: {
deps: ['backbone']
}
},
map: {
'*': {
'css': 'vendor/require-css/css'
}
}
});
require(['jquery', 'app'], function ($, App) {
'use strict';
$(function () {
App.start();
});
});
requirejs: {
dist: {
// Options: https://github.com/jrburke/r.js/blob/master/build/example.build.js
options: {
// `name` and `out` is set by grunt-usemin
baseUrl: 'app/scripts',
// optimize: 'none',
// TODO: Figure out how to make sourcemaps work with grunt-usemin
// https://github.com/yeoman/grunt-usemin/issues/30
//generateSourceMaps: true,
// required to support SourceMaps
// http://requirejs.org/docs/errors.html#sourcemapcomments
preserveLicenseComments: false,
useStrict: true,
wrap: true
//uglify2: {} // https://github.com/mishoo/UglifyJS2
}
}
},
define(['backbone',
'jquery',
'collections/articles',
'css!styles/app'], function (Backbone, $, Articles) {
var AppView = Backbone.View.extend({
initialize: function (options) {
this.router = options.router;
this.articles = new Articles();
this.articles.fetch();
},
render: function () {
this.$el.html('<p>Hello world</p>');
return this;
}
});
return AppView;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment