From f975d22994df00cce7a29004a83157abed0d7ae4 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sun, 24 May 2015 08:45:56 -0400 Subject: [PATCH] add server task --- tasks/server.coffee | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tasks/server.coffee diff --git a/tasks/server.coffee b/tasks/server.coffee new file mode 100644 index 000000000..ce11fa59a --- /dev/null +++ b/tasks/server.coffee @@ -0,0 +1,21 @@ +module.exports = (grunt) -> + express = require("express") + compression = require("compression") + readYaml = require('read-yaml'); + + serverConfig = readYaml.sync("config/server.yml") + + grunt.registerTask "server", "static file development server", => + 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 +