Comments (9)
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.
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.
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.
Start a new pull request in StackBlitz Codeflow.
from vite.
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.
server.hmr
option changes the behavior of HMR connection and doesn't affect how files are served. The HMR connection path is correctly changed tows://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.
How can I see this is the case?
You can see it in the network tab of dev tools.
what is the option to change the hot file contents from something like
http://localhost:5173
to something likehttp://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.
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.
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)
- 5.4.3 production bug HOT 2
- Improper escaping of HTML attribute when `transformIndexHtml` is used HOT 1
- failed CSS preloads prevent loading dependencies HOT 1
- [vite:css] [postcss] ENOENT: no such file or directory
- Issues with dynamic import of static JS file HOT 2
- Modifications to the `server.proxy` in the plugin API `configureServer` did not take effect HOT 1
- Testing files are not excluded on prod build HOT 2
- `fetchpriority` attribute in `<script>` is stripped from `index.html` after build HOT 2
- An option to inject CSS styles into the generated .html files <head> tag instead of separate .css files
- When importing wrong local files shows no error. HOT 4
- Expose dev, preview URLs as env variables. HOT 2
- Share chunks between multiple ESM Workers HOT 1
- CSS module prefix query parameter HOT 3
- Create Vite - Remix - "remix command not found" HOT 3
- Not detected recurrence in scss code (@mixin calling itself) leading to build failure HOT 5
- `vite build` can fail when resolving root `tsconfig.json` extends HOT 2
- Add a plugin hook like 'insertTagsToHtml' to support dynamic public path in the index.html
- The output code execution results of the ts code compiled by vite and the code compiled by tsc are inconsistent HOT 4
- React component in node_modules doesn't fast-refresh HOT 2
- The results of code compiled with vite and code compiled directly with esbuild are inconsistent,Decorators related issues HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vite.