Skip to content
This repository has been archived by the owner on Feb 10, 2024. It is now read-only.

frontend watcher help #1

Open
AlexBitsTech opened this issue Mar 26, 2022 · 4 comments
Open

frontend watcher help #1

AlexBitsTech opened this issue Mar 26, 2022 · 4 comments

Comments

@AlexBitsTech
Copy link

AlexBitsTech commented Mar 26, 2022

I'm trying to get the HMR to work with vite and wails on Windows.

Up until today with the beta.33 version of wails V2 I had no luck making the HMR work. It wouldn't build whether I put vite build --watch in the frontend:dev:watcher of the wails.json directly or if I created the script in package.json with an npm run <script> in the frontend:dev:watcher.

With the new beta.34 version it seems the vite build --watch in the frontend:dev:watcher works. However, when it reloads, it put the wails window in a 404 state and I have to right click -> reload for the changes to be visible.

I get this error on hot reload:

transforming (17) src\App.svelteERR | Error processing request '/': open <path>\frontend\dist/index.html: The system cannot find the file specified. (HttpResponse=Body: '', StatusCode: 404)

Do you have any idea how I can fix this?

@BillBuilt
Copy link
Owner

I still don't use any of the frontend:* commands at all.

Here's my scripts section of package.json

  "scripts": {
    "vite": "vite",
    "dev": "vite build --watch",
    "build": "vite build",
    "preview": "vite preview",
    "check": "svelte-check --tsconfig ./tsconfig.json"
  },

and my wails.json

  "frontend:build": "npm run build",
  "frontend:install": "npm install",
  "frontend:dev": "",
  "frontend:dev:watcher": "",
  "wailsjsdir": "./frontend",

I do have to have 2 terminals open, first running npm run dev in the /frontend dir. Once that finishes I go to the second terminal and run wails dev in the root dir. Having vite build --watch for npm run dev causes Vite to build and watch for changes (but not launch a server). This works really well but after a while I do feel the need to CTRL-C and re-run the wails dev command.

I have not been able to play with the beta.34 version yet but I know some work was being made towards trying to solve these issues. Right after beta.33 landed I tried it out and had mixed results but it looked promising and I wanted to mention it in the readme.

@BillBuilt
Copy link
Owner

I had a few mintes to try out beta.34 and it went better than my experience with beta.33 but I only had time to do some very basic testing of the watch-change-reload processes. I did have issues using vite build --watch directly in the frontend:dev:watcher flag and instead just used npm run dev (which still calls vite build --watch) so maybe try that. I have updated the readme accordingly.

@AlexBitsTech
Copy link
Author

Thanks for the reply!
I had to install vite globally (npm install i -g vite) in order to be able to have it work in the wails.json
I feel like wails almost nails it. It does compile and launch (all in one terminal) and it does recompile when I make changes to the source code.
The only issue is that because the wails GUI refreshes before vite has time to finish recompiling, I get a 404 on the wails GUI. This is easily solvable with a right click -> refresh on the wails GUI however so not so much of a hassle.
It would be convenient however if the auto-refresh happened after compilation

@BillBuilt
Copy link
Owner

I'm sure they'd love to hear your experience with this. Might want to open an issue over at Wails. They're relly good about reponding to them. I think issues around Vite is pertty high on the list of priorities for them at the moment.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants