Skip to content
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

Support pre-build hook with wails dev & wails build #1577

Closed
SgtPooki opened this issue Jul 16, 2022 · 3 comments · Fixed by #1578
Closed

Support pre-build hook with wails dev & wails build #1577

SgtPooki opened this issue Jul 16, 2022 · 3 comments · Fixed by #1578
Labels
awaiting feedback More information is required from the requestor Ready For Testing A fix is available and needs testing
Milestone

Comments

@SgtPooki
Copy link

SgtPooki commented Jul 16, 2022

Is your feature request related to a problem? Please describe.

The problem is that my team already has built our front-end assets, and we just need to include it in our desktop app (https://github.com/ipfs/ipfs-desktop).

You can see in the README of https://github.com/SgtPooki/ipfs-desktop-wails, that we don't need a front-end command to run at all, but we do need a command to run to get our prebuilt frontend (see https://github.com/SgtPooki/ipfs-desktop-wails#run-a-local-version).

Since we need to get these front-end assets between wails dev and wails generate module, we get errors unless we run an explicit command prior to running wails. I believe it would be wise for wails to offer a solution for the multitude of usecases a preBuildHook could support.

Describe the solution you'd like

wails.json already has postBuildHooks, I would like to propose preBuildHooks. Essentially an agnostic version of "frontend:*" though not necessarily a replacement.

For my issue, I would only need to run ./get-webui.sh in the preBuildHook:

wails.json

...
    "preBuildHooks": {
        "*/*": "./get-webui.sh"
    }
...

Describe alternatives you've considered

The only two solutions I could think of that allow us to fully bundle our webui in the app (obtaining via runtime is not a viable solution) are:

  1. require build process to run our get-webui.sh shell script prior to running wails command
  2. move .get-webui.sh to ./frontend/get-webui.sh and set "frontend:build": "bash ./get-webui.sh", in wails.json

Solution 1

This works, and is okay, but definitely not ideal, requires build cmd to be:

./get-webui.sh && wails build # or wails dev

at least on the first run.

Solution 2

This is currently what I'm using as it's the desired DX I want. See SgtPooki/ipfs-desktop-wails@fab2491

but allows us to have a single canonical wails build command:

wails build # or wails dev

Some issues with this solution that others may run into

With no ./frontend folder:
╰─ ✔ ❯ wails dev -v 2
Wails CLI v2.0.0-beta.38


Executing: go mod tidy -compat=1.17
Executing: wails generate module


ERROR:
main.go:10:12: pattern frontend: no matching files found
with existing ./frontend/.gitkeep
╰─ ✔ ❯ wails dev -v 2
Wails CLI v2.0.0-beta.38


Executing: go mod tidy -compat=1.17
Executing: wails generate module


ERROR:
main.go:10:12: pattern frontend: cannot embed directory frontend: contains no embeddable files

exit status 1

If Wails is useful to you or your company, please consider sponsoring the project:
https://github.com/sponsors/leaanthony


exit status 1
With empty ./frontend/index.html

This allows things to work, but I don't like the idea that wails could be modifying/hooking into a file that will be overwritten.

Additional context

No response

@leaanthony leaanthony added the TODO The issue is ready to be developed label Jul 16, 2022
@leaanthony leaanthony added this to the v2.0.0 milestone Jul 16, 2022
@leaanthony
Copy link
Member

Thanks for the amazingly detailed enhancement request. Should be trivial to implement this and I can see the need.

@leaanthony
Copy link
Member

leaanthony commented Jul 16, 2022

@SgtPooki - Please check the linked PR. Is this what you had in mind?
Updated the docs here: https://0b961860.wails-website.pages.dev/docs/next/reference/project-config

@leaanthony leaanthony added awaiting feedback More information is required from the requestor Ready For Testing A fix is available and needs testing and removed TODO The issue is ready to be developed labels Jul 16, 2022
@SgtPooki
Copy link
Author

SgtPooki commented Jul 17, 2022

@leaanthony This is amazing. Your PR nails the interface I want. I am not the right person to speak to how you implemented it, but I believe the surface area is absolutely what I needed!

Thank you so much for throwing this together so fast. I was not expecting a response this quickly! =D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting feedback More information is required from the requestor Ready For Testing A fix is available and needs testing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants