[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.
Ruslan Lesiutin committed
Oct 20, 2025 at 13:39 UTC
02c80f0d8702cb894f6ef9748e7b18ffdd388a55
3 files changed
+29
-8
packages/react-devtools-extensions/src/main/cloneStyleTags.js
+27
-6
@@ -1,5 +1,14 @@
1
-function cloneStyleTags() {
2
- const linkTags = [];
1
+/**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow
8
+ */
9
+
10
+export function cloneStyleTags(): Array<HTMLLinkElement | HTMLStyleElement> {
11
+ const tags: Array<HTMLLinkElement | HTMLStyleElement> = [];
12
13
// eslint-disable-next-line no-for-of-loops/no-for-of-loops
14
for (const linkTag of document.getElementsByTagName('link')) {
@@ -11,11 +20,23 @@ function cloneStyleTags() {
20
newLinkTag.setAttribute(attribute.nodeName, attribute.nodeValue);
21
}
22
14
- linkTags.push(newLinkTag);
23
+ tags.push(newLinkTag);
24
}
25
}
26
18
- return linkTags;
19
-}
27
+ // eslint-disable-next-line no-for-of-loops/no-for-of-loops
28
+ for (const styleTag of document.getElementsByTagName('style')) {
29
+ const newStyleTag = document.createElement('style');
30
+
31
+ // eslint-disable-next-line no-for-of-loops/no-for-of-loops
32
+ for (const attribute of styleTag.attributes) {
33
+ newStyleTag.setAttribute(attribute.nodeName, attribute.nodeValue);
34
+ }
35
21
-export default cloneStyleTags;
36
+ newStyleTag.textContent = styleTag.textContent;
37
+
38
+ tags.push(newStyleTag);
39
+ }
40
+
41
+ return tags;
42
+}
packages/react-devtools-extensions/src/main/index.js
+1
-1
@@ -33,7 +33,7 @@ import {
33
import {viewAttributeSource} from './sourceSelection';
34
35
import {startReactPolling} from './reactPolling';
36
-import cloneStyleTags from './cloneStyleTags';
36
+import {cloneStyleTags} from './cloneStyleTags';
37
import fetchFileWithCaching from './fetchFileWithCaching';
38
import injectBackendManager from './injectBackendManager';
39
import registerEventsLogger from './registerEventsLogger';
packages/react-devtools-extensions/webpack.config.js
+1
-1
@@ -285,7 +285,7 @@ module.exports = {
285
{
286
loader: 'css-loader',
287
options: {
288
- sourceMap: true,
288
+ sourceMap: __DEV__,
289
modules: true,
290
localIdentName: '[local]___[hash:base64:5]',
291
},