-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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 does not support external URLs with the development server
#2196
Comments
The solution is to simply configure your Laravel app to serve the assets in vite directory. I personally don't know how to do that but this should be a common feature in all backend frameworks. There are already integrations like https://github.com/innocenzi/laravel-vite so I'm pretty sure this is not a limitation. |
@yyx990803 The backend can be configured easily to include the CSS/Js/Ts/etc. scripts/files based on the environment with no problem. However, the problem comes in with static assets (images, fonts, etc.) included from within these types of files, where a backend will have no control over the generated URLs. For example, a CSS file in Laravel would request assets from |
@yyx990803 Any possibility this issue could be reopened? More effort has been put into implementing workarounds in https://github.com/innocenzi/laravel-vite but the core problems still exists. |
@yyx990803 I can confirm that this is an issue, and we don't have a proper solution yet. Other back-ends (Symfony, Ruby) have this issue too. @ElMassimo has a workaround for his Ruby package, but this is mostly a hack and I think this should be handled on Vite's side. I think @SirDavidLudwig's idea of having an environment variable or configuration option would be a solid fix. If I understand correctly, this environment variable (or configuration option) should be used there in order to handle everything properly? EDIT: monkey-patching the return value of |
I'm too experiencing this issue (not with Laravel though, with Craft CMS as a backend). As @innocenzi has mentioned, I think this is a generic problem for server-side rendered backends that I'd love to see resolved. |
@SirDavidLudwig I did see that... unfortunately this is a case where I can't really patch Vite itself because other people will be using the scaffolding I'm working on. Very much appreciate the pointer tho! |
@khalwat I see. Well, might I also suggest looking into generating patch files using something like patch-package. With it, it will apply these patches will automatically for everyone. Just wanted to throw that out there in case it might work for your needs |
Don't want to be pushy but could we at least reopen this issue? I'm trying to get Vite working with Craft, too, and this is the biggest blocker right now. |
Agree, would love to see this re-opened, I referenced it here: https://nystudio107.com/blog/using-vite-js-next-generation-frontend-tooling-with-craft-cms#vite-processed-assets ...and it is still an issue, at least imo. |
I prefer a built-in solution, but for now I'm using a proxy as a work around, since I'm using docker for my backend development this is really easy, of course you can apply a similar fix to your needs.
|
如果使用laravel valet 可新增驱动,让驱动控制资源加载,具体如:
|
This issue has been locked since it has been closed for more than 14 days. If you have found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest Vite version. If you have any other comments you should join the chat at Vite Land or create a new discussion. |
Describe the bug
The
base
option currently does not support the ability to specify external URLs when serving content through the development server. This greatly limits the incorporation of Vite into other backends (Laravel, etc.) as static assets can no longer be served since the assets are served on a different port than the web server. I explored this specific problem in more depth in a separate issue by attempting to integrate Vite into a Laravel project.As a solution suggestion, I believe that this issue would be solved best by implementing an environment variable to specify a URL
base
for content served specifically through the dev server. This would resolve these issues with backend compatibility and allow for the most flexability in users' dev environments.Reproduction
I'm not sure how worthwhile a reproduction guide is for this issue, but this should give you something to compare against.
vue-ts
project using the@vitejs/app
init scriptvite.config.ts
:npm run dev
andnpm run build && npm run serve
. Thesrc
attribute of the<img>
tag will only contain the base ofhttp://localhost:3000/
on production builds.System Info
vite
version:2.0.1
Ubuntu 20.10
14.15.4
npm
Logs (Optional if provided reproduction)
N/A
The text was updated successfully, but these errors were encountered: