-
-
Save brianfeister/5818796 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//assume that Backbone and $ are available as globals | |
//everything in this file will be interpretted as soon as the JS is | |
//loaded by the browser. | |
var MainRouter = require('./2-mainRouter'); //A Backbone Router | |
//doc ready | |
$(function () { | |
router = new MainRouter(); | |
Backbone.history.start({pushState: true}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//again, anything in the global scole is interpretted on JS load by the browser | |
//this is loaded immediately | |
window.test = 'testing'; | |
//whereas this will be defined and picked up by the require statement | |
module.exports = Backbone.Router.extend({ | |
routes: { | |
'foo/bar': 'doFooBar' | |
}, | |
doFooBar: function () { | |
//route fn | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//browserify task | |
module.exports = function(grunt) { | |
//This will figure out the dependency graph of every file in the client/js tree (eg the two files above). | |
//They'll be concatenated into a single output file (app.js). | |
//Keep in mind that the doc.ready call is like a `main()` fn for your app. | |
//It's also possible to get fancier here: you can make certain required files accessible | |
//from the global scope (using externalize), you can alias files to different names, | |
//you can perform dynamic transformations during browserify compilation. But this is the start. | |
grunt.initConfig({ | |
browserify: { | |
"app": { | |
dest: 'public/js/app.js', | |
src: 'client/js/**/*.js' | |
options: { | |
debug: true | |
} | |
} | |
}, | |
}); | |
grunt.loadNpmTasks('grunt-browserify'); | |
grunt.registerTask('default', ['browserify']); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment