Commit 5cc8261c authored by Daniel Gerhardt's avatar Daniel Gerhardt

Start server with Grunt run task

A web server for static resources and a proxy to the backend API are
now started with the run task.

ARSnova Mobile no longer relies on the backend to provide the frontend
application files. In consequence, the development environment is more
flexible. The local repositories can be located independently and it is
possible to deploy the backend as WAR file on an application server
instead of using the Maven jetty:run goal. This should ease the setup
process for pure frontend developers.

Additionally, the newly provided development environment is much closer
to the recommended production setup. The frontend is located at /mobile
while the API is accessible at /api.
parent b539d06f
......@@ -19,6 +19,45 @@ module.exports = function (grunt) {
build: buildPath
},
connect: {
server: {
options: {
base: buildPath + "/<%= senchaEnv %>/ARSnova",
hostname: "localhost",
port: 8081,
useAvailablePort: true,
open: true,
middleware: function (connect, options) {
var proxy = require("grunt-connect-proxy/lib/utils").proxyRequest;
return [
["/", function (req, res, next) {
if ("/" === req.url) {
res.writeHead(301, {Location: "/mobile"});
res.end();
} else {
/* Let the proxy middleware handle this request */
next();
}
}],
/* Serve static files */
["/mobile", connect.static(options.base[0])],
/* Proxy for backend API */
proxy
];
}
},
proxies: [
{
context: ["/", "/api", "/arsnova-config"],
host: "localhost",
port: 8080,
xforward: true
}
]
}
},
jscs: {
all: {
src: lintJs
......@@ -102,11 +141,18 @@ module.exports = function (grunt) {
});
/* we want Grunt for this task to continue even if QA checks fail */
grunt.option("force", true);
grunt.task.run(["newer:jscs", "newer:jshint"]);
grunt.task.run([
"newer:jscs",
"newer:jshint",
"configureProxies:server",
"connect"
]);
grunt.task.run("watch");
});
grunt.loadNpmTasks("grunt-connect-proxy");
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-contrib-connect");
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-jscs");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment