From 277e2254ad4c12ea9f785a4488a8d2d35a0279c8 Mon Sep 17 00:00:00 2001 From: Dan Zajdband Date: Wed, 11 Jan 2017 11:29:12 -0300 Subject: [PATCH 1/2] Added webpack dynamic import routes to the router. --- server/index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server/index.js b/server/index.js index f50c6779c1a44..0f873fcf535f9 100644 --- a/server/index.js +++ b/server/index.js @@ -80,6 +80,13 @@ export default class Server { const p = join(__dirname, '..', 'client', ...(params.path || [])) await serveStatic(req, res, p) }) + + this.router.get('/_webpack/:number', async (req, res, params) => { + if (isNaN(params.number)) throw new Error('Webpack dynamic imports should be numbered') + const p = join(this.dir, `.next/${params.number}`) + await serveStaticWithGzip(req, res, p) + }) + this.router.get('/static/:path+', async (req, res, params) => { const p = join(this.dir, 'static', ...(params.path || [])) await serveStatic(req, res, p) From 83af14c3ca028006f58c785c4772c46c8cac89bc Mon Sep 17 00:00:00 2001 From: Dan Zajdband Date: Wed, 11 Jan 2017 12:05:15 -0300 Subject: [PATCH 2/2] Joining path with join instead of template string --- server/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/index.js b/server/index.js index 0f873fcf535f9..b40d67eaef97d 100644 --- a/server/index.js +++ b/server/index.js @@ -83,7 +83,7 @@ export default class Server { this.router.get('/_webpack/:number', async (req, res, params) => { if (isNaN(params.number)) throw new Error('Webpack dynamic imports should be numbered') - const p = join(this.dir, `.next/${params.number}`) + const p = join(this.dir, '.next', params.number) await serveStaticWithGzip(req, res, p) })