Rewrote build.js using cheerio.

I got frustrated with the current build script's limitations, so I rewrote it using CheerioJS (which is already used by the Node script). It is now more readable, though admittedly has a slight runtime performance hit.

Output should be structurally identical, but with slightly different whitespace.