Add sourceURL comment to all compiled js files

This commit is contained in:
Max Brunsfeld
2015-08-21 11:19:11 -07:00
parent 8b7f9b0471
commit 408202729e

View File

@@ -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({