code-dot-org/code-dot-org — pull request #527 by wjordan (2014-11-22 00:59:28+00:00)
Title: Blockly bundle locales

This PR dramatically reduces the amount of time to build our Blockly-based JavaScript apps.

Before (only building English and pseudolocalized locales):
```
$ time grunt rebuild
[...]
Done, without errors.

real	0m37.081s
```
After (building ALL locales):
```
$ time grunt rebuild
[...]
Done, without errors.

real	0m15.949s
```
It also reduces the payload size of the final files:
Before:
```
196218 /en_us/bounce.min.js
160441 /en_us/calc.min.js
227974 /en_us/eval.min.js
193261 /en_us/flappy.min.js
154157 /en_us/jigsaw.min.js
278952 /en_us/maze.min.js
341921 /en_us/studio.min.js
274640 /en_us/turtle.min.js
167866 /en_us/webapp.min.js
```
After:
```
48375 /bounce.min.js
12458 /calc.min.js
203850 /common.min.js
18625 /eval.min.js
45315 /flappy.min.js
13356 /jigsaw.min.js
132228 /maze.min.js
117503 /studio.min.js
128540 /turtle.min.js
25735 /webapp.min.js
```

The only tradeoff is that we now load four `script` tags in our `_blockly.html.haml` view partial, instead of one, to grab the proper localized strings from for the app-specific and the common bundles:
```haml
%script{src: "#{blockly_path}js/common#{pretty ? '' : '.min'}.js"}
%script{src: "#{blockly_path}js/#{js_locale}/common_locale.js"}
%script{src: "#{blockly_path}js/#{js_locale}/#{app}_locale.js"}
%script{src: "#{blockly_path}js/#{app}#{pretty ? '' : '.min'}.js"}
```

I've also added a new dev-mode script, `./up`, that uses [foreman](https://github.com/ddollar/foreman) to serve Pegasus and Dashboard and watch/rebuild dev-mode Blockly all from the same command, that might be helpful when working on features across each project.