From 4f0b3366278a66860ed444874c9efa3eb99f188a Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sat, 16 Dec 2017 20:30:14 -0500 Subject: [PATCH] fix prod mode --- lib/index.js | 2 ++ lib/utils/create_compiler.js | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/index.js b/lib/index.js index 8fa8552..10ce4c3 100644 --- a/lib/index.js +++ b/lib/index.js @@ -62,6 +62,8 @@ module.exports = function connect(opts) { 'Cache-Control': 'max-age=31536000' }); res.end(compiler.asset_cache[url]); + } else { + next(); } } } diff --git a/lib/utils/create_compiler.js b/lib/utils/create_compiler.js index 1a4fe33..ef2dccb 100644 --- a/lib/utils/create_compiler.js +++ b/lib/utils/create_compiler.js @@ -16,10 +16,10 @@ module.exports = function create_compiler(client, server, dest, routes, dev) { compiler.client_main = `/client/${info.assetsByChunkName.main}`; compiler.assets = info.assets.map(asset => `/client/${asset.name}`); - const fs = client.outputFileSystem; + const _fs = client.outputFileSystem && client.outputFileSystem.readFileSync ? client.outputFileSystem : fs; compiler.asset_cache = {}; compiler.assets.forEach(file => { - compiler.asset_cache[file] = fs.readFileSync(path.join(dest, file), 'utf-8'); + compiler.asset_cache[file] = _fs.readFileSync(path.join(dest, file), 'utf-8'); }); } @@ -137,7 +137,11 @@ module.exports = function create_compiler(client, server, dest, routes, dev) { new Promise((fulfil, reject) => { server.run((err, stats) => { - server_updated(err, stats, reject); + if (stats.hasErrors()) { + reject(stats.toJson().errors[0]); + } else { + server_updated(stats); + } fulfil(); }); })