[DevTools] fix: dont ship source maps for css in prod builds (#34913)

This has been causing some issues with the submission review on Firefox
store: we use OS-level paths in these source maps, which makes the build
artifact different from the one that's been submitted.

Also saves ~100Kb for main.js artifact.
This commit is contained in:
Ruslan Lesiutin 2025-10-20 13:39:42 +01:00 committed by GitHub
parent 21272a680f
commit 02c80f0d87
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 29 additions and 8 deletions

View File

@ -1,5 +1,14 @@
function cloneStyleTags() { /**
const linkTags = []; * Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
export function cloneStyleTags(): Array<HTMLLinkElement | HTMLStyleElement> {
const tags: Array<HTMLLinkElement | HTMLStyleElement> = [];
// eslint-disable-next-line no-for-of-loops/no-for-of-loops // eslint-disable-next-line no-for-of-loops/no-for-of-loops
for (const linkTag of document.getElementsByTagName('link')) { for (const linkTag of document.getElementsByTagName('link')) {
@ -11,11 +20,23 @@ function cloneStyleTags() {
newLinkTag.setAttribute(attribute.nodeName, attribute.nodeValue); newLinkTag.setAttribute(attribute.nodeName, attribute.nodeValue);
} }
linkTags.push(newLinkTag); tags.push(newLinkTag);
} }
} }
return linkTags; // eslint-disable-next-line no-for-of-loops/no-for-of-loops
} for (const styleTag of document.getElementsByTagName('style')) {
const newStyleTag = document.createElement('style');
export default cloneStyleTags; // eslint-disable-next-line no-for-of-loops/no-for-of-loops
for (const attribute of styleTag.attributes) {
newStyleTag.setAttribute(attribute.nodeName, attribute.nodeValue);
}
newStyleTag.textContent = styleTag.textContent;
tags.push(newStyleTag);
}
return tags;
}

View File

@ -33,7 +33,7 @@ import {
import {viewAttributeSource} from './sourceSelection'; import {viewAttributeSource} from './sourceSelection';
import {startReactPolling} from './reactPolling'; import {startReactPolling} from './reactPolling';
import cloneStyleTags from './cloneStyleTags'; import {cloneStyleTags} from './cloneStyleTags';
import fetchFileWithCaching from './fetchFileWithCaching'; import fetchFileWithCaching from './fetchFileWithCaching';
import injectBackendManager from './injectBackendManager'; import injectBackendManager from './injectBackendManager';
import registerEventsLogger from './registerEventsLogger'; import registerEventsLogger from './registerEventsLogger';

View File

@ -285,7 +285,7 @@ module.exports = {
{ {
loader: 'css-loader', loader: 'css-loader',
options: { options: {
sourceMap: true, sourceMap: __DEV__,
modules: true, modules: true,
localIdentName: '[local]___[hash:base64:5]', localIdentName: '[local]___[hash:base64:5]',
}, },