Skip to content

Instantly share code, notes, and snippets.

@justinmc
Created October 13, 2014 01:08
Show Gist options
  • Save justinmc/e143e7ff5027db2eba86 to your computer and use it in GitHub Desktop.
Save justinmc/e143e7ff5027db2eba86 to your computer and use it in GitHub Desktop.
A simple example of how to share code between the front and back ends. This file could be run in either environment and work in both, without code duplication.
var config = {
version: '3.1.4'
};
// Frontend
if (window) {
window.config = config;
// Backend
} else if (typeof module !== 'undefined' && module.exports) {
module.exports = config;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment