diff --git a/server/build/webpack.js b/server/build/webpack.js index 8ce712910721f..7fd93d5749e99 100644 --- a/server/build/webpack.js +++ b/server/build/webpack.js @@ -247,8 +247,23 @@ export default async function createCompiler (dir, { dev = false, quiet = false, inputSourceMap: sourceMap }) + // Strip ?entry to map back to filesystem and work with iTerm, etc. + let { map } = transpiled + let output = transpiled.code + + if (map) { + map.sources = map.sources.map((source) => source.replace(/\?entry/, '')) + delete map.sourcesContent + + // Output explicit inline source map that source-map-support can pickup via requireHook mode. + // Since these are not formal chunks, the devtool infrastructure in webpack does not output + // a source map for these files. + const sourceMapUrl = new Buffer(JSON.stringify(map), 'utf-8').toString('base64') + output = `${output}\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,${sourceMapUrl}` + } + return { - content: transpiled.code, + content: output, sourceMap: transpiled.map } } diff --git a/server/index.js b/server/index.js index 7ddce95c12fe5..1900ccfd52edb 100644 --- a/server/index.js +++ b/server/index.js @@ -29,6 +29,14 @@ const blockedPages = { export default class Server { constructor ({ dir = '.', dev = false, staticMarkup = false, quiet = false, conf = null } = {}) { + // When in dev mode, remap the inline source maps that we generate within the webpack portion + // of the build. + if (dev) { + require('source-map-support').install({ + hookRequire: true + }) + } + this.dir = resolve(dir) this.dev = dev this.quiet = quiet