wailsapp / wails

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

wails dev: option to skip "frontend:dev", rebuild app if a file is requested from the devserver which was not included but is present #1275

Closed bearsh closed 2 years ago

bearsh commented 2 years ago

Is your feature request related to a problem? Please describe. I'm using wails with a frontend created by the create-react-app script. Unfortunately create-react-app does not support live-reloading in combination with a output folder (it serves the pages from memory). A third party application (cra-build-watch) exists which can be used as watcher. This script only features a watch mode and after starting it deletes the output folder. this causes the go build to not include the generated files and the devserver fails to serve them.

Describe the solution you'd like As cra-build-watch deletes the output folder on start, using the "frontend:dev" command doesn't make sense in this case. so an option to skip this step would be nice. Furthermore the cra-build-watch script has a option to call a hook after first rebuild. this could be used to signal wails the frontend is ready to be included.

Describe alternatives you've considered A simple alternative it to configure cat as "frontend:dev" command and once the watcher is finished, change a go file to trigger a reload on the go side.

Additional context See also https://github.com/AlienRecall/wails-react-template/pull/2 especially https://github.com/AlienRecall/wails-react-template/pull/2/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5

stffabi commented 2 years ago

PR https://github.com/wailsapp/wails/pull/1290 is up, which adds support for external dev servers. So you are able to use an external dev in wails.

Would be great if you could give it a try with the following changes in your project.json

  "frontend:dev:watcher": "[Command to start the react dev server]",
  "frontend:dev:serverUrl": "[http://localhost:3000 url to the react dev server]",
misitebao commented 2 years ago

@stffabi @leaanthony For this question and other related questions, I have an idea, since we can support frontend:dev:serverUrl, can we also manually specify the entry file or path, like winloadfilefilepath in electron Same.

Because I see that we have plans to support multiple windows, there will definitely be API additions or adjustments in the future. Currently, the index.html file in the front-end resource directory is searched by default. I think it can be used as a default option. We need a You can manually specify the entry method, which can be a file or a URL, and it is also convenient for users to adapt to API upgrades in the future.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

leaanthony commented 2 years ago

@misitebao let's move the request for a url/filepath to another ticket 👍