The backbone build system provides a development environment to build backbone apps so that you don't have to build your own system. It can do the following:
- Provide the capability of using CommonJS for your modules, minifying your JavaScript into a single bundle on save, and provide tiny production bundles (with browserify and its plugins tinyify and watchify).
- Browserify transform for _.template to support stand alone *.tmpl files with node-underscorify.
- Use backbone without jQuery (with browserify's exclude feature). Without jQuery you'll need these small changes:
- Use Backbone.NativeView in place of Backbone.View.
- Use Backbone.NativeAjax for Backbone.ajax.
- Mouse free browser refresh on file save (with browsersync).
- Serve gzip bundles so you can test your bundles in a simulated production environment (with http-server and gzip). This can be useful when running Lighthouse.
$ npm installWhile editing and saving files, these two commands provide you with the following during development.
Open 2 terminals:
Terminal 1 - Start the dev web server, which refreshes the browser(s) on file save.
$ npm startTerminal 2 - Start the dev environment which builds a dev bundle on file save.
$ npm run devThis is useful for building your production bundles.
$ npm run build$ npm start-prodColorize your underscore templates with Underscore Template Colorizer.
I found this introductory helpful for those new to backbone.js or those in need of a refresher: Backbone, The Primer