Skip to content

Instantly share code, notes, and snippets.

@jkresner
Created April 13, 2013 09:05
Show Gist options
  • Save jkresner/5377677 to your computer and use it in GitHub Desktop.
Save jkresner/5377677 to your computer and use it in GitHub Desktop.
Deploy brunch to heroku
console.log "app node file", process.cwd()
mongoose = require 'mongoose'
express = require 'express'
app = express()
app.configure ->
app.use express.static(__dirname + '/public')
app.use express.bodyParser()
require('./app_routes')(app)
mongoUri = process.env.MONGOHQ_URL || 'mongodb://localhost/airpair_dev'
mongoose.connect mongoUri
db = mongoose.connection
db.on('error', console.error.bind(console, 'connection error:'))
db.once 'open', ->
console.log 'connected to db'
exports.startServer = (port, path, callback) ->
p = process.env.PORT || port
console.log "startServer on port: #{p}, path #{path}"
app.listen p
isHeroku = process.env.MONGOHQ_URL?
if isHeroku
exports.startServer()
{config} = require './config'
config.server.port = 5000
config.files.javascripts.joinTo =
# note removed test files from the release build
'test/javascripts/test.js': /^test(\/|\\)(?!vendor)/
'test/javascripts/test-vendor.js': /^test(\/|\\)(?=vendor)/
exports.config = config
# See docs at http://brunch.readthedocs.org/en/latest/config.html.
exports.config =
server:
path: 'app.coffee', port: 3333, base: '/', run: yes
files:
javascripts:
joinTo:
'javascripts/app.js': /^app/
'javascripts/vendor.js': /^vendor/
'test/javascripts/test.js': /^test(\/|\\)(?!vendor)/
'test/javascripts/test-vendor.js': /^test(\/|\\)(?=vendor)/
order:
# Files in `vendor` directories are compiled before other files
# even if they aren't specified in order.
before: [
'vendor/scripts/jquery.js'
'vendor/scripts/lodash.js'
'vendor/scripts/backbone.js'
]
stylesheets:
joinTo:
'stylesheets/app.css': /^(app|vendor)/
'test/stylesheets/test.css': /^test/
order:
before: [
'vendor/styles/normalize.css',
'vendor/styles/bootstrap.css'
]
after: ['vendor/styles/helpers.css']
templates:
joinTo: 'javascripts/app.js'
{
"author": "Jonathon Kresner",
"name": "airpair.com",
"description": "site hosted at airpair.com",
"version": "0.0.1",
"homepage": "http://airpair.com/",
"repository": {
"type": "git",
"url": ""
},
"engines": {
"node": "0.8.x",
"npm": "1.1.x"
},
"scripts": {
"postinstall": "brunch build -c config-release.coffee"
},
"dependencies": {},
}
web: ./node_modules/.bin/coffee app.coffee
@konsumer
Copy link

konsumer commented May 8, 2014

in app.coffee, I do this, instead, and it works for anything that requires vs runs directly:

if require.main is module
    exports.startServer()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment