embark-area-51/boilerplate/tasks/server.coffee

23 lines
615 B
CoffeeScript
Raw Normal View History

2015-07-23 02:32:30 +00:00
module.exports = (grunt) ->
express = require('express')
compress = require('compress')
readYaml = require('read-yaml')
grunt.registerTask "server", "static file development server", =>
serverConfig = readYaml.sync("config/server.yml")
webPort = serverConfig.port || 8000
webHost = serverConfig.host || 'localhost'
webRoot = "generated/dapp"
app = express()
app.use(compression())
app.use(express.static("" + (process.cwd()) + "/" + webRoot))
app.listen(webPort, webHost)
grunt.log.writeln("Running web server on port http://#{webHost}:#{webPort}")
return app