I'm working on a single page app that requires several third-party libs. To reduce build time I'm trying to create two separate bundles: one for the libs code and one for the app code. My build process uses grunt-browserify to generate the bundles. Here's my browserify task (I'm using grunt-load-tasks to modularize my Grunt tasks):
var libs = [
'backbone',
'backbone-relational',
'backbone.babysitter',
'backbone.wreqr',
'bootstrap',
'bootstrap-growl',
'handlebars',
'jquery',
'marionette',
'underscore'
];
module.exports = {
options: {
external: libs
},
libs: {
src: [],
dest: './build/js/libs.js',
options: {
external: null,
require: libs
}
},
app: {
src: ['./frontend/js/app.coffee'],
dest: './build/js/app.js',
options: {
browserifyOptions: {
debug: true,
extensions: ['.coffee'],
},
watch: true
}
}
}
This successfully creates the two separate bundles and my app is functional after including the bundles on the page. However I'm noticing that Backbone and Handlebars are being included in both the libs.js bundle and the app.js bundle when I would have expected them to be included only in the libs.js bundle. Any idea what I'm doing wrong?