wailsapp / wails

Create beautiful applications using Go
https://wails.io
MIT License
23.49k stars 1.12k forks source link

About `tailwindcss` and `AssetServer.Handle` With `v2.5.1` #2718

Closed fzdwx closed 1 year ago

fzdwx commented 1 year ago

Description

When I upgraded from version 2.4.1 to 2.5.1, I found that both Tailwind and my custom AssetHandle were not working in my project.

This is after the upgrade:

image

This is before the upgrade:

image

To Reproduce

Use Wails 2.4.1 and 2.5.1 respectively to start.

git clone https://github.com/fzdwx/launcher.git
wails dev

Expected behaviour

Normal use of Tailwind and AssetHandle.

Screenshots

No response

Attempted Fixes

No response

System Details

Wails CLI v2.4.1

Scanning system - Please wait (this may take a long time)...Done.

# System

OS           | Arch Linux
Version      | Unknown
ID           | arch
Go Version   | go1.20.5
Platform     | linux
Architecture | amd64

# Wails

Version         | v2.4.1
Package Manager | pacman

# Dependencies

Dependency | Package Name | Status    | Version
*docker    | docker       | Installed | 1:24.0.2-1
gcc        | gcc          | Installed | 13.1.1-1
libgtk-3   | gtk3         | Installed | 1:3.24.38-1
libwebkit  | webkit2gtk   | Installed | 2.40.2-1
npm        | npm          | Installed | 8.19.2-2
pkg-config | pkgconf      | Installed | 1.8.1-1
* - Optional Dependency

# Diagnosis

Your system is ready for Wails development!
 ♥   If Wails is useful to you or your company, please consider sponsoring the project:
https://github.com/sponsors/leaanthony

Additional context

No response

fzdwx commented 1 year ago

Update:

  1. tailwindcss can work properly now, I added import './style.css' in main.ts, But I was able to work normally without this line of code in v2.4.1.
leaanthony commented 1 year ago

Thanks for reporting. Have you investigated what change may have caused this?

fzdwx commented 1 year ago

About AssetHandle may be related to custom protocols, I did not return a 501 status code.

image

image

fzdwx commented 1 year ago

I'm trying to find that commit, I referenced the commit 7c1490a, my Asset handler was working fine, but in the next commit, my program turned white, and the situation got worse.

image

stffabi commented 1 year ago

The CSS thing is a known issue on Linux since we consolidated the devserver to use the custom scheme 'wails://'. Either you can import the css as you've already mentioned or bump your webkit build dependency by using 'wails dev -tag webkit2_36'

As for the assethandler that's strange, I was not able to reproduce this issue with my test prpject. Can you provide your console output to see if thr handler get called or not? Most often when '501 - not implemented' is returned this means the custom handler did not return any data. Does probably your if statement in there not catch and the handler just returns? Can you check if the handler is called at all?

fzdwx commented 1 year ago

I confirm

image

qwe

stffabi commented 1 year ago

Okey and can you test if your if is reached? Can you add some printf to the line where you do the rw.Write to check that gets reached? And does it work id you explicitly call a rw.WriteHeader(200) ?

fzdwx commented 1 year ago

Thinks, the reason is that req.RequestURI returned the complete path wails://wails.localhost:34115/favicon.ico?/linguist.

stffabi commented 1 year ago

Great you got it solved. Interesting I would not have expected that the RequestURI did change between 2.4 and 2.5

stffabi commented 1 year ago

This did really change between 2.4 and 2.5 and the 2.4 behaviour is the correct one. This is an issue with our faking Go-Webserver, will provide a PR soon to fix this so we conform the the HTTP RFC for this value.

fzdwx commented 1 year ago

Ok,