feature: add hideDarkMode option to control the toggle #123
+17
−5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Add a configuration option: hideDarkMode, which can control the visibility of the Dark Mode toggle button.
The background is that the Vue DevTools project has a bug (#737) and issue #339. The main idea is that DevTools wants its theme to be isolated from the project’s theme. However, since vite-plugin-inspect uses VueUse's useDark method, it causes issues with theme isolation and also triggers bug #737. The best solution is to hide this button in DevTools, and this PR implements that functionality.
Linked Issues
vuejs/devtools#737 (comment)
vuejs/devtools#736
vuejs/devtools#339
Additional context
The method I used to modify the route is not very elegant. I tried many approaches, but none of them worked perfectly due to various issues. The main reason is that the __inspect page itself is a static resource, and it's difficult to make the hideDarkMode configuration penetrate into Inspect through Vite’s configuration.
Therefore, I decided to differentiate at the stage when the static web resource server starts. It is hard to achieve this requirement through environment variables or other Vite-injected variables. If anyone has a better solution, I would appreciate your guidance. Thank you!