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

Base option not used in HMR url #288

Closed
markieo1 opened this issue Mar 5, 2024 · 3 comments · Fixed by #290
Closed

Base option not used in HMR url #288

markieo1 opened this issue Mar 5, 2024 · 3 comments · Fixed by #290
Assignees

Comments

@markieo1
Copy link

markieo1 commented Mar 5, 2024

Vite Plugin Version

1.0.2

Laravel Version

10.42.0

Node Version

20.9.0

NPM Version

10.1.0

Operating System

Windows (WSL)

OS Version

1.2.5.0

Web browser and version

Google Chrome Version 122.0.6261.95 (Official Build) (64-bit)

Running in Sail?

No

Description

I have just upgraded from Vite 4 to 5. And have also upgraded the plugin.
I have set the base option to: /frontend/. When we have a look at the hot file that is generated by the url we see the following url:
https://vite-issue.test:5173.
When we disable the Laravel Vite plugin, so just using the native implementation from Vite itself the following URL is generated (from: https://vite-issue.test:5173/frontend/@vite/client):

const socketHost = `${"vite-issue.test" || importMetaUrl.hostname}:${hmrPort || importMetaUrl.port}${"/frontend/"}`;

Seeing this, the Laravel Vite plugin should also take into account the base option. So that the url in the hot file is: https://vite-issue.test:5173/frontend/

The following config is used in this situation:

import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import fs from 'node:fs'

const host = 'vite-issue.test';

export default defineConfig({
    base: '/frontend/',
    plugins: [
        laravel({
            input: 'src/main.ts',
        }),
    ],
    server: {
        host,
        hmr: { host },
        https: {
            key: fs.readFileSync(`./vite-issue.test.key`),
            cert: fs.readFileSync(`./vite-issue.test.crt`),
        },
    },
});

Steps To Reproduce

  • Ensure there's a key and cert file available for your site.
  • Configure Vite as specified.
  • Start Vite: npm run dev
  • The generated url in the hotfile is https://vite-issue.test:5173. Instead of https://vite-issue.test:5173/frontend/.
@driesvints
Copy link
Member

1.6.1

This version doesn't exists. Which one are you running?

@markieo1
Copy link
Author

markieo1 commented Mar 5, 2024

1.6.1

This version doesn't exists. Which one are you running?

Sorry, it is the latest 1.0.2. I've changed the description.

@timacdonald
Copy link
Member

Thanks for reporting this. We have a fix at #290. I will close this and we can monitor the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants