diff --git a/src/compile-cache.js b/src/compile-cache.js index 0f2554efb..c30f03105 100644 --- a/src/compile-cache.js +++ b/src/compile-cache.js @@ -61,7 +61,7 @@ function compileFileAtPath (compiler, filePath, extension) { var cachePath = compiler.getCachePath(sourceCode, filePath) var compiledCode = readCachedJavascript(cachePath) if (compiledCode == null) { - compiledCode = compiler.compile(sourceCode, filePath) + compiledCode = addSourceURL(compiler.compile(sourceCode, filePath), filePath) writeCachedJavascript(cachePath, compiledCode) } return compiledCode @@ -84,6 +84,12 @@ function writeCachedJavascript (relativeCachePath, code) { fs.writeFileSync(cachePath, code, 'utf8') } +function addSourceURL (jsCode, filePath) { + if (process.platform === 'win32') + filePath = '/' + path.resolve(filePath).replace(/\\/g, '/') + return jsCode + '\n' + '//# sourceURL=' + encodeURI(filePath) + '\n' +} + var INLINE_SOURCE_MAP_REGEXP = /\/\/[#@]\s*sourceMappingURL=([^'"\n]+)\s*$/mg require('source-map-support').install({