Browse Source

Merge branch 'patch'

master
Lloyd Brookes 8 years ago
parent
commit
0cabf0d30f
  1. 19
      lib/local-web-server.js
  2. 1
      package.json

19
lib/local-web-server.js

@ -164,6 +164,16 @@ function localWebServer (options) {
}
})
/* for any URL not matched by static (e.g. `/search`), serve the SPA */
if (options.spa) {
const historyApiFallback = require('koa-connect-history-api-fallback')
debug('SPA', options.spa)
app.use(historyApiFallback({
index: options.spa,
verbose: options.verbose
}))
}
/* serve static files */
if (options.static.root) {
const serve = require('koa-static')
@ -176,15 +186,6 @@ function localWebServer (options) {
app.use(serveIndex(options.serveIndex.path, options.serveIndex.options))
}
/* for any URL not matched by static (e.g. `/search`), serve the SPA */
if (options.spa) {
const send = require('koa-send')
debug('SPA', options.spa)
app.use(_.all('*', function spa (ctx, route, next) {
const root = path.resolve(options.static.root) || process.cwd()
return send(ctx, options.spa, { root: root }).then(next)
}))
}
return app
}

1
package.json

@ -40,6 +40,7 @@
"koa-bodyparser": "^3.0.0",
"koa-compress": "^1.0.9",
"koa-conditional-get": "^1.0.3",
"koa-connect-history-api-fallback": "^0.3.0",
"koa-convert": "^1.2.0",
"koa-etag": "^2.1.1",
"koa-json": "^1.1.1",

Loading…
Cancel
Save