Last active
August 29, 2015 14:07
-
-
Save skullbulb/a7c2ead6120c7dca152c to your computer and use it in GitHub Desktop.
Backbone.Marionette with Grunt and Browserify
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
var LayoutView = require('./views/LayoutView.js'); | |
new LayoutView(); |
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
module.exports = function(grunt) { | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
browserify: { | |
vendor: { | |
src: 'src/js/vendor.js', | |
dest: 'dist/js/vendor.js', | |
options: { | |
alias: [ | |
'./node_modules/handlebars/runtime.js:handlebars', | |
'./node_modules/lodash/dist/lodash.underscore.js:underscore', | |
'jquery:', | |
'backbone:', | |
'backbone.marionette:' | |
] | |
} | |
}, | |
application: { | |
src: 'src/js/application.js', | |
dest: 'dist/js/application.js', | |
options: { | |
browserifyOptions: { | |
debug: true | |
}, | |
external: [ | |
'handlebars', 'underscore', 'jquery', 'backbone', 'backbone.marionette' | |
] | |
} | |
} | |
}, | |
watch: { | |
scripts: { | |
files: 'src/js/**/*.js', | |
tasks: ['browserify:application'], | |
} | |
} | |
}); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
grunt.loadNpmTasks('grunt-browserify'); | |
grunt.registerTask('default', ['browserify:vendor', 'browserify:application', 'watch']); | |
}; |
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
var Marionette = require('backbone.marionette'), | |
_ = require('underscore'); // return lodash instance | |
module.exports = Marionette.LayoutView.extend({ | |
initialize: function () { | |
console.log('Lodash version', _.VERSION); | |
} | |
}); |
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
{ | |
"name": "sample", | |
"version": "1.0.0", | |
"description": "Your Application", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC", | |
"devDependencies": { | |
"grunt": "^0.4.5", | |
"grunt-browserify": "^3.0.1", | |
"grunt-contrib-watch": "^0.6.1" | |
}, | |
"dependencies": { | |
"backbone": "^1.1.2", | |
"handlebars": "^2.0.0", | |
"jquery": "^2.1.1", | |
"lodash": "^2.4.1", | |
"backbone.marionette": "^2.2.1" | |
} | |
} |
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
require('backbone').$ = require('jquery'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment