Hi all. This is my first time bringing up an article on this forum. Please let me know if I’m not following the generally accepted conventions.
My situation: I have an app that has approx 15-20kloc not including external dependencies. Currently I am using Brunch as a build tool. The problem with this is that it compiles everything in my app (app, routes, controllers, views, templates, etc.) into one single file that needs to be loaded on startup. Minified, just the app.js file generated by Brunch is about 1.25MB. And it’s only going to get bigger. That app.js combined with jQuery, Ember, Ember Data, Handlebars, and other libraries combines for close to 2MB. I am aware the enabling gzip on my server will help a lot but that initial app load will still be in the 300-400KB range.
It makes sense to me to not load the resources a particular route needs until the route is accessed. For that reason, I am attempting to switch things over to a lazy-load policy. My attempts are going to be based on this article: http://madhatted.com/2013/6/29/lazy-loading-with-ember. In order to do this, I will need my controllers, views, and templates (and any other dependencies) each in separate files to be loaded on the fly. With Brunch I get the flexibility for “brunch watch” to automatically compile things and deploy to an output (including pre-compiling *.hbs files into .js).
I am looking for any thoughts, suggestions, and/or solutions for accomplishing this lazy loading ability with the following:
- Ability to “watch” for app changes to automatically re-build
- Option to build minified js even when there is no concatenation
- Precompile handlebars templates and output to their own files (also w/ option to be minified - although this isn’t that important because you can’t really debug hbs files)
I know I can accomplish the minification and handlebars compiling with my own script with uglify and handlebars but I also value the immediate builds when files change (especially when styling a page and making frequent changes). I can’t see an easy way to “watch” my app for changes while also pre-compiling hbs and minifying.
I am open to any process. I’d appreciate any help.