Skip to content

Instantly share code, notes, and snippets.

@jmervine
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmervine/e20757e2c0e9e7d2ecb4 to your computer and use it in GitHub Desktop.
Save jmervine/e20757e2c0e9e7d2ecb4 to your computer and use it in GitHub Desktop.
// ... app.js ...
//
// In the below examples replace 'development' (and 'production') with
// the actual NODE_ENV passed, for example we use 'dev' for development
// and 'prod' for production.
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
if (process.env.NODE_ENV === 'development') {
app.set('view cache', false);
} else {
app.set('view cache', true);
}
// NOTE: Searching for this, most results will produce the older way of doing this.
// This is no longer the recommended way because 'app.configure' is removed in
// Express 4.x, and if you haven't already, I recommend upgrading to it before
// releasing or ASAP if you've already released.
//
// The old way:
app.configure(function() {
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
});
app.configure('production', function() {
app.set('view cache', true);
});
app.configure('development', function() {
app.set('view cache', false);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment