run webpack in watch mode during dev

This commit is contained in:
Rich Harris
2017-12-16 16:50:46 -05:00
parent 71ed3864b7
commit 5995b7ae6a
6 changed files with 54 additions and 31 deletions

View File

@@ -69,14 +69,13 @@ module.exports = function connect(opts) {
req.params = route.exec(url);
const chunk = compiler.chunks[route.id];
const mod = require(path.resolve(dest, 'server', chunk));
const mod = require(compiler.server_routes)[route.id];
if (route.type === 'page') {
let data = { params: req.params, query: req.query };
if (mod.default.preload) data = Object.assign(data, await mod.default.preload(data));
if (mod.preload) data = Object.assign(data, await mod.preload(data));
const { html, head, css } = mod.default.render(data);
const { html, head, css } = mod.render(data);
const page = templates.render(200, {
main: compiler.client_main,