Skip to content

Commit

Permalink
feat: show devtools client url in terminal (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
webfansplz authored Dec 18, 2023
1 parent 40eba39 commit 166b3b2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/vite/src/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Inspect from 'vite-plugin-inspect'
import VueInspector from 'vite-plugin-vue-inspector'
import { setupViteRPCServer } from '@vue-devtools-next/core'
import { setupAssetsRPC, setupGraphRPC } from '@vue-devtools-next/core/server'
import { bold, dim, green, yellow } from 'kolorist'
import { bold, cyan, dim, green, yellow } from 'kolorist'
import { DIR_CLIENT } from './dir'

type DeepRequired<T> = {
Expand Down Expand Up @@ -88,10 +88,17 @@ export default function VitePluginVueDevTools(options?: VitePluginVueDevToolsOpt
rpc: inspect.api.rpc,
}),
})

const _printUrls = server.printUrls
const colorUrl = (url: string) =>
cyan(url.replace(/:(\d+)\//, (_, port) => `:${bold(port)}/`))

server.printUrls = () => {
const urls = server.resolvedUrls!
const keys = normalizeComboKeyPrint('option-shift-d')
_printUrls()
for (const url of urls?.local)
console.log(` ${green('➜')} ${bold('Vue DevTools')}: ${green(`Open ${colorUrl(`${url}__devtools__/`)} as a separate window`)}`)
console.log(` ${green('➜')} ${bold('Vue DevTools')}: ${green(`Press ${yellow(keys)} in App to toggle the Vue DevTools`)}\n`)
}
}
Expand Down

0 comments on commit 166b3b2

Please sign in to comment.