Giter VIP home page Giter VIP logo

Comments (9)

ionut-mihalache avatar ionut-mihalache commented on September 23, 2024 1

Ok, thank you for your help. I am using Laravel, but I did not know that the plugin creates the hot file. I will open an issue on the Laravel Vite Plugin git repo.

from vite.

github-actions avatar github-actions commented on September 23, 2024

Hello @ionut-mihalache. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with needs reproduction will be closed if they have no activity within 3 days.

from vite.

ionut-mihalache avatar ionut-mihalache commented on September 23, 2024

I added a very simple example at https://stackblitz.com/edit/vitejs-vite-7xkluq?file=vite.config.js. I expect /custom/path to be visible and used when serving assets. It is ok to expect this or is there some other setting that I am missing.

In this example if we look at client in the network tab, we find this https://vitejsvite7xkluq-1ecl--5173--34455753.local-credentialless.webcontainer.io/@vite/client. I would expect to be something like this https://vitejsvite7xkluq-1ecl--5173--34455753.local-credentialless.webcontainer.io//custom/path/@vite/client in my case.

I know about the base option, but I want to use that for production builds and not for development.

from vite.

stackblitz avatar stackblitz commented on September 23, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

from vite.

sapphi-red avatar sapphi-red commented on September 23, 2024

server.hmr option changes the behavior of HMR connection and doesn't affect how files are served. The HMR connection path is correctly changed to ws://localhost:5173/custom/path.

I know about the base option, but I want to use that for production builds and not for development.

What is the reason for that?

from vite.

ionut-mihalache avatar ionut-mihalache commented on September 23, 2024

server.hmr option changes the behavior of HMR connection and doesn't affect how files are served. The HMR connection path is correctly changed to ws://localhost:5173/custom/path.

How can I see this is the case? Neither the hot file or the network tab in the browser reflect this. The files seem to be served from the root path and that leads to NOT_FOUND error.

I know about the base option, but I want to use that for production builds and not for development.
What is the reason for that?

I tried to use the base option but it seems like it is not working because in production the expectation is that the asset directory is the build directory, so in this case I would set the base to /custom/path/build/; this works in production (npm run build), but not in development (npm run dev).

If you say that is possible to get the expected behavior at the moment, then what is the proper way to 'force' the development server to serve me the assets from my custom path. The documentation is not quite clear about this (maybe this is too particular but I don't think that it is uncommon to have a site at a domain path, not at the root domain).

Or put more simply, what is the option to change the hot file contents from something like http://localhost:5173 to something like http://localhost:5173/custom/path/...?

Thank you.

from vite.

sapphi-red avatar sapphi-red commented on September 23, 2024

How can I see this is the case?

You can see it in the network tab of dev tools.
image

what is the option to change the hot file contents from something like http://localhost:5173 to something like http://localhost:5173/custom/path/...?

I don't get what you mean by "hot file". But setting base: '/custom/path/' would make assets served from /custom/path/*.
If you mean you want to serve files after build from /custom/path/build/ and, in dev from /custom/path/, then you can use conditional configs.

export default defineConfig(({ command }) => ({
  base: command === 'serve' ? '/custom/path/' : '/custom/path/build/'
}))

from vite.

ionut-mihalache avatar ionut-mihalache commented on September 23, 2024

I don't get what you mean by "hot file". But setting base: '/custom/path/' would make assets served from /custom/path/*. If you mean you want to serve files after build from /custom/path/build/ and, in dev from /custom/path/, then you can use conditional configs.

When running npm run dev there is a file called hot created that contains the URL for the assets (at least that seems to be the case for me). The file content is just an url in the form of http://localhost:5173. If I manually change the contents of this created hot file to whatever I want the url to be, what I want works.

So the question is if there is a way to change the contents of that created file called hot from the vite.config.js because I can't obtain this effect at the moment (or I am missing something regarding this).

from vite.

sapphi-red avatar sapphi-red commented on September 23, 2024

Vite doesn't generate a file named hot. I guess it's something that a plugin generates. Laravel Vite Plugin seems to generate a file named hot. If you are using that, it's not something Vite itself controls.

from vite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.