2015-05-24 12:45:56 +00:00
|
|
|
module.exports = (grunt) ->
|
|
|
|
express = require("express")
|
|
|
|
compression = require("compression")
|
2015-06-28 02:20:07 +00:00
|
|
|
readYaml = require('read-yaml')
|
2015-05-24 12:45:56 +00:00
|
|
|
|
|
|
|
grunt.registerTask "server", "static file development server", =>
|
2015-06-28 02:20:07 +00:00
|
|
|
serverConfig = readYaml.sync("config/server.yml")
|
|
|
|
|
2015-05-24 12:45:56 +00:00
|
|
|
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
|
|
|
|
|