diff --git a/build/lib/extensions.js b/build/lib/extensions.js index c6d56319c30..4e704bdab6f 100644 --- a/build/lib/extensions.js +++ b/build/lib/extensions.js @@ -158,10 +158,12 @@ function fromLocalWebpack(extensionPath, webpackConfigFileName, disableMangle) { // source map handling: // * rewrite sourceMappingURL // * save to disk so that upload-task picks this up - const contents = data.contents.toString('utf8'); - data.contents = Buffer.from(contents.replace(/\n\/\/# sourceMappingURL=(.*)$/gm, function (_m, g1) { - return `\n//# sourceMappingURL=${sourceMappingURLBase}/extensions/${path.basename(extensionPath)}/${relativeOutputPath}/${g1}`; - }), 'utf8'); + if (path.extname(data.basename) === '.js') { + const contents = data.contents.toString('utf8'); + data.contents = Buffer.from(contents.replace(/\n\/\/# sourceMappingURL=(.*)$/gm, function (_m, g1) { + return `\n//# sourceMappingURL=${sourceMappingURLBase}/extensions/${path.basename(extensionPath)}/${relativeOutputPath}/${g1}`; + }), 'utf8'); + } this.emit('data', data); })); }); diff --git a/build/lib/extensions.ts b/build/lib/extensions.ts index 2a9a215c5e4..14f2de9fef5 100644 --- a/build/lib/extensions.ts +++ b/build/lib/extensions.ts @@ -170,10 +170,12 @@ function fromLocalWebpack(extensionPath: string, webpackConfigFileName: string, // source map handling: // * rewrite sourceMappingURL // * save to disk so that upload-task picks this up - const contents = (data.contents).toString('utf8'); - data.contents = Buffer.from(contents.replace(/\n\/\/# sourceMappingURL=(.*)$/gm, function (_m, g1) { - return `\n//# sourceMappingURL=${sourceMappingURLBase}/extensions/${path.basename(extensionPath)}/${relativeOutputPath}/${g1}`; - }), 'utf8'); + if (path.extname(data.basename) === '.js') { + const contents = (data.contents).toString('utf8'); + data.contents = Buffer.from(contents.replace(/\n\/\/# sourceMappingURL=(.*)$/gm, function (_m, g1) { + return `\n//# sourceMappingURL=${sourceMappingURLBase}/extensions/${path.basename(extensionPath)}/${relativeOutputPath}/${g1}`; + }), 'utf8'); + } this.emit('data', data); }));