| 65 | } |
| 66 | |
| 67 | async function extractAndRemoveSourceMappingUrl(resource) { |
| 68 | const resourceContent = await resource.getString(); |
| 69 | const resourcePath = resource.getPath(); |
| 70 | const sourceMappingUrlMatch = resourceContent.match(sourceMappingUrlPattern); |
| 71 | if (sourceMappingUrlMatch) { |
| 72 | const sourceMappingUrl = sourceMappingUrlMatch[1]; |
| 73 | if (log.isLevelEnabled("silly")) { |
| 74 | log.silly(`Found source map reference in content of resource ${resourcePath}: ${sourceMappingUrl}`); |
| 75 | } |
| 76 | |
| 77 | // Strip sourceMappingURL from the resource to be minified |
| 78 | // It is not required anymore and will be replaced for in the minified resource |
| 79 | // and its debug variant anyways |
| 80 | resource.setString(resourceContent.replace(sourceMappingUrlPattern, "")); |
| 81 | return sourceMappingUrl; |
| 82 | } |
| 83 | return null; |
| 84 | } |
| 85 | |
| 86 | async function getSourceMapFromUrl({sourceMappingUrl, resourcePath, readFile}) { |
| 87 | // ======================================================================= |