Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin hook for when vite opens the browser #18596

Closed
4 tasks done
rtabulov opened this issue Nov 6, 2024 · 1 comment
Closed
4 tasks done

plugin hook for when vite opens the browser #18596

rtabulov opened this issue Nov 6, 2024 · 1 comment

Comments

@rtabulov
Copy link

rtabulov commented Nov 6, 2024

Description

it would be nice if you added a new hook for when vite opens the browser.

in our team we have a 'mirror-plugin' in one of our projects which mirrors the same app on another port, so that we have additional ports when using vite dev command, we use it something like this

    plugins: [
        react(),
        mirrorPlugin(3021),
        mirrorPlugin(3022),
    ],

we wanted to also open these ports (url) in browser when vite opens the browser
the problem is we open the urls on configureServer hook at server.httpServer.on('listening', ...) after checking server.config.server.open, but this does not really reflect when the browser is actually opened by vite.

it would be nice to have a hook for when vite opens the browser for a plugin like ours.

Suggested solution

add a vite plugin hook for when vite opens the browser, something like browserOpened

Alternative

No response

Additional context

No response

Validations

@patak-dev
Copy link
Member

I don't know if there is a good way for us to expose this new hook, and this hasn't been a need other users have asked so far. You could add a middleware to check when the browser sends the first request to know that is has been opened and use that to implement this feature.

@patak-dev patak-dev closed this as not planned Won't fix, can't repro, duplicate, stale Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants