From 98ed518bdc5e365a3e8ed812842ce4f747a15f3b Mon Sep 17 00:00:00 2001 From: jhen Date: Sun, 23 Jul 2023 12:15:01 +0800 Subject: [PATCH] Fix react-devtools not auto detect system theme --- scripts/patch-modules.js | 19 +++++++++++++++++++ scripts/postinstall.js | 2 ++ 2 files changed, 21 insertions(+) create mode 100644 scripts/patch-modules.js diff --git a/scripts/patch-modules.js b/scripts/patch-modules.js new file mode 100644 index 00000000..e3137a37 --- /dev/null +++ b/scripts/patch-modules.js @@ -0,0 +1,19 @@ +const shell = require('shelljs'); +const path = require('path'); + +console.log('Patch react-devtools-core'); + +const rdStandalone = path.join( + __dirname, + '../dist/node_modules/react-devtools-core/dist/standalone.js' +); + +// Make react-devtools-core to auto detect theme +// We still use this patch because patch-package to patch js bundle is not very ideal +shell.sed( + '-i', + // eslint-disable-next-line + /bridge:e,browserTheme:t="light"/, + 'bridge:e,browserTheme:t="auto"', + rdStandalone +); diff --git a/scripts/postinstall.js b/scripts/postinstall.js index 6ee28a05..659b5217 100755 --- a/scripts/postinstall.js +++ b/scripts/postinstall.js @@ -15,6 +15,8 @@ async function run() { '-rf', 'node_modules/apollo-client-devtools/{assets,build,development,shells/dev,src}' ); + // eslint-disable-next-line + require('./patch-modules'); } run();