Skip to content

Feature: Set UI panel defaults from the Plugin #532

Description

@SeanCassiere

Clear and concise description of the problem

Not being able to define the UI defaults for the devtools panel in such a way that can live in your codebase- means that every fresh instance needs a developer to go into the panel and setup those desired codebase defaults, before any actual dev-server usage can properly happen.

This stemmed from me wanting to disable the default Cmd + K global keyboard trigger and figuring out that such a thing had to be manually done by every dev on the team in across their browsers. This becomes worse if you are using worktrees and launching the dev server and passing in the --port flag since you'd need to go through all this again.

Also, as someone who needs to regularly clear their web storage, for clean runs - its becoming annoying that this needs to keep being done.

Suggested solution

I think having an object in the vite plugin for setting the default UI options would make sense.

Something like:

// vite.config.ts
import { DevTools } from '@vitejs/devtools'
import Inspect from 'vite-plugin-inspect'
import { defineConfig } from 'vitest/config'

export default defineConfig(() => {
  return {
    plugins: [
      DevTools({
        // like this
        uiOptions: {
          shortcuts: {
            open:  "Cmd+K"
          }
        }
      }),
      Inspect(),
    ],
  }
})

Alternative

I think TanStack Devtools gets around this by having the devtools be a component that's mounted into the framework's tree, so that means the defaults are set on the component itself - <Devtools config={{ openHotkey: [] }} />. This wouldn't make sense here since the devtools are injected in by vite and not by the UI-framework.

You could try and hack something in by having a dev-only script be fired to check for window.__VITE_DEVTOOLS_CLIENT_CONTEXT__ and if so try and work with that - but this definitely feels like a hack/work-around.

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions