Build remotely
At the simplest end of the scale is GitHub Pages, which uses Jekyll to build the app on GitHub’s servers:
The config files and source code are in the root directory of a gh-pages branch.
Jekyll builds the source HTML/MD, CSS/SASS and JS/CS files to a
_sitedirectory - this is where the app is served from.For third-party libraries, you can either download production-ready code manually to a
libfolder and include them, or install with Bower to abower_componentsfolder and include them directly from there.
The benefit of this approach is that you can edit the source files through GitHub’s web interface, and the site will update without needing to do any local building or deployment.
Jekyll will build all CSS/SASS files (including those pulled in from bower_components) into a single CSS file. However, it doesn’t yet have something similar for JS/CoffeeScript. If this was available it would be ideal, as then the bower_components folder could be left out of the built app.
Build locally, deploy the built app as a separate branch
If the app is being built locally, there are several steps that can be taken to improve the process:
Keep the config files in the root folder, but move the app’s source files into an
appfolder.Use Gulp to build the Bower-managed third-party libraries alongside the app’s own styles and scripts.
While keeping the source files in the master branch, use Gulp to deploy the built app in a separate gh-pages branch.
A good example of this is the way that the Yeoman generator for scaffolding a Polymer app structures a project (other Yeoman generators are similar):
In the master branch, install/build-related files are in the root folder (run
npm installandbower installto fetch third-party components, usebower linkfor any independent local components).The actual app source files (index.html, app styles, app-specific elements) are in the app folder.
gulpbuilds all the HTML, CSS/SASS and JS source files to thedistfolder;gulp servemakes the built files available over HTTP and reloads on changes;gulp deploypushes thedistfolder to a remote gh-pages branch.