-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
Dynamic assets not loading in dev mode since updating vite to v5.0.0+ #3240
Comments
I tried the following while keeping vite 5.0.0+:
I am puzzled as to why the above config changes do not work with vite 5.0.0+ |
I believe the answer is somewhere in here: vitejs/vite#8452 |
Setting |
thanks @leaanthony
I get the expected behaviour in the console:
But the app (working from the template) looks like: with the console reporting errors:
so the app will probably need some changes as well. I will investigate later, other work issues to deal with first |
with
so is the issue shifted away from vite, to the ExternalAssetHandler? |
Where is the request for "." coming from? |
I have no idea. The code is from the vue-ts template with only the view
config changed.
Also I have just setup vscode to debug the app. There is no issue when
using the vscode debug
Benoit
…On Wed, 7 Feb 2024, 18:35 Lea Anthony, ***@***.***> wrote:
Where is the request for "." coming from?
—
Reply to this email directly, view it on GitHub
<#3240 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACML4A7255G4TRMEGNMNWYTYSPCORAVCNFSM6AAAAABC33AN5SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZSGY2DINBZHE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
No that is perfectly fine. Because now Vite returns a 404 error, the request is forwarded to the assethandler. The problem is that now Vite does not work anymore for SPA or MPA, due to using |
That's when requesting the '/' and indicates which file would have been loaded from the |
Does bun have a Dev server/bundler? 😉 |
Spitballing here.... What if you registered a path prefix with your middleware so a matching request isn't forwarded to the external server at all? |
so far I have tried a few things(separately):
none worked. |
@stffabi - what if we tried the custom handlers first and forwarded to vite only if that failed? |
That would unfortunately change the current behaviour completely. Currently the I will try to take an in-depth look this week, to see what we could do. |
Understood that it would change the current behaviour and we don't need to address this until v3 as vite 4 still works fine. If we needed to change behaviour, then we could have that as an option and leave the default. I was just speculating that a workflow of |
I personally would leave the behaviour as it is for v2 and for v3 I would completely drop the |
Love it! Sounds like a plan! |
@BenoitBotton I guess the answer for this ticket is that unless you can find a way to make vite 5 work with its new behaviour and defaults, we recommend staying with Vite 4. |
yes, I thought it was going that way. is there a need to update
documentation for the dynamic handler? I am happy to do it (easy first
contribution to a project)
|
After taking a look into v3, I think we should keep the
This allows people that don't want to use the @leaanthony thoughts? |
Does that mean if you want to serve up, say, an image, you have to use POST? Could we not check the path and if it starts with |
One can do that with the We can still drop I'm open to whatever you want. I personally would not introduce some magic paths like My preferred solution would be probably like this: Let's just drop the Using an app := application.New(application.Options{
Assets: application.AssetOptions{
Handler: application.AssetFileServerFS(assets),
}, And if someone wants to have a custom path for images that get dynamically served, this would look like the following with e.g. chi: r := chi.NewRouter()
r.Get("/images/*", func(w http.ResponseWriter, r *http.Request) {
fmt.Println("My Images dynamically served")
w.WriteHeader(http.StatusOK)
})
r.NotFound(application.AssetFileServerFS(assets).ServeHTTP)
app := application.New(application.Options{
Assets: application.AssetOptions{
Handler: r,
}, Example with mux := &http.ServeMux{}
mux.Handle("/", application.AssetFileServerFS(assets))
mux.HandleFunc("/images/", func(w http.ResponseWriter, r *http.Request) {
fmt.Println("My Images dynamically served")
w.WriteHeader(http.StatusOK)
})
app := application.New(application.Options{
Assets: application.AssetOptions{
Handler: mux,
}, |
Just pushed the above proposal to |
We can see this issue as closed. There's currently nothing we can do regarding Vite v5+ and for Wails v3 we have changed the implementation so this is not a problem anymore. |
Description
since updating to vite 5.0.0+, dynamic assets are not served anymore when running
wails dev
, but the index.html file is instead. things are fine once compiledTo Reproduce
in a brand new project, follow the step in the dynamic assets example

whether fetching a non-exiting file or go.mod, the index.html file gets served
I have a repo with an example and troubleshooting steps: https://github.com/BenoitBotton/assethandler
Expected behaviour
expect files to get served or an error produced as in the example
Screenshots
No response
Attempted Fixes
No response
System Details
Additional context
No response
The text was updated successfully, but these errors were encountered: