Skip to content
This repository has been archived by the owner on Jan 6, 2024. It is now read-only.

Commit

Permalink
fix: inject inspector client manually to ensure devtools hook registe…
Browse files Browse the repository at this point in the history
…r normally
  • Loading branch information
webfansplz committed Aug 8, 2023
1 parent f5ac779 commit cd71414
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
3 changes: 2 additions & 1 deletion packages/client/logic/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ function subscribeHook() {
const client = useDevToolsClient()
const hook = client.value.hook
hook.on(DevToolsHooks.APP_INIT, (app) => {
if (app?._vueDevtools_hidden_)
if (!app || app._instance.type?.devtools?.hide)
return

vueApp.value = app
instance.value = app._instance
})
Expand Down
2 changes: 1 addition & 1 deletion packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"execa": "^7.2.0",
"sirv": "^2.0.3",
"vite-plugin-inspect": "^0.7.35",
"vite-plugin-vue-inspector": "^3.5.0"
"vite-plugin-vue-inspector": "^3.6.0"
},
"devDependencies": {
"@types/node": "^20.4.8",
Expand Down
12 changes: 11 additions & 1 deletion packages/node/src/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,15 @@ export default function VitePluginVueDevTools(options?: VitePluginVueDevToolsOpt
src: '/@id/virtual:vue-devtools-path:app.js',
},
},
// inject inspector script manually to ensure it's loaded after vue-devtools
{
tag: 'script',
injectTo: 'head',
attrs: {
type: 'module',
src: '/@id/virtual:vue-inspector-path:load.js',
},
},
],
}
},
Expand All @@ -187,10 +196,11 @@ export default function VitePluginVueDevTools(options?: VitePluginVueDevToolsOpt

return [
VueInspector({
lazyLoad: pluginOptions.appendTo ? 200 : false,
toggleComboKey: '',
toggleButtonVisibility: 'never',
openInEditorHost: pluginOptions.openInEditorHost,
...(pluginOptions.appendTo ? { appendTo: pluginOptions.appendTo } : {}),
appendTo: pluginOptions.appendTo || 'manually',
}),
plugin,
inspect,
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cd71414

Please sign in to comment.