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

feat: Add support for vite serve #6765

Merged
merged 2 commits into from
Dec 16, 2024
Merged

feat: Add support for vite serve #6765

merged 2 commits into from
Dec 16, 2024

Conversation

mejo-
Copy link
Member

@mejo- mejo- commented Dec 10, 2024

Fixes: #6732

🚧 TODO

  • Add support for a nginx config drop-in to nextcloud-docker-dev

🏁 Checklist

  • Code is properly formatted (npm run lint / npm run stylelint / composer run cs:check)
  • Sign-off message is added to all commits
  • Documentation (README or documentation) has been updated or is not required

@mejo- mejo- self-assigned this Dec 10, 2024
@mejo- mejo- force-pushed the feat/vite_serve branch 2 times, most recently from 0eb33fa to 3dd2f2f Compare December 10, 2024 15:36
@max-nextcloud
Copy link
Collaborator

Thanks a lot for looking into this. ❤️ I'm super happy this works.

I have two suggestions:

  • use a non-standart port and add it to the vite config. Then we can hardcode the same port in nextcloud-docker-dev for text. I suggest 7347 😉.
  • I will look into making use of vite/@client instead of the middleware. It looks like that rewrites the module urls inside the browser and could replace the middleware. See step 2 of https://v5.vite.dev/guide/backend-integration.html

@max-nextcloud
Copy link
Collaborator

max-nextcloud commented Dec 11, 2024

I tried to follow the instructions.
It proved a bit challenging to get the changes to nginx applied. Whenever i restarted the proxy container my changes were gone. So I tried to add the locations and then ran /etc/init.d/nginx restart. This printed some errors about not being able to bind but then at least my config would have an effect.

However now I am seeing this in the proxy logs:

proxy-1      | nginx.1     | 2024/12/11 09:34:19 [error] 63#63: *9 connect() failed (101: Network is unreachable) while connecting to upstream, client: 192.168.23.1, server: nextcloud.local, request: "GET /apps/text/js/text-init.mjs HTTP/1.1", upstream: "http://192.168.15.1:5173/apps/text/js/text-init.mjs", host: "nextcloud.local"

Maybe the ip addresses are different for me?

Update ahh... reading helps

Replace '192.168.15.1' with the IP of your docker host.

@mejo-
Copy link
Member Author

mejo- commented Dec 11, 2024

Thanks for testing it out @max-nextcloud. I added support for a nginx config drop-in to nextcloud-docker-dev in the meantime: juliusknorr/nextcloud-docker-dev#367

This approach is also the reason why I'd keep the default port of vite serve: we won't add the configuration for forwarding Text request to vite serve to nextcloud-docker-dev anyway. But in future it's as simple as running npm run serve in Text repo and adding the small snippet to data/nginx/vhost.d/nextcloud.local in nextcloud-docker-dev and that's it.

Maybe the ip addresses are different for me?

Yes, that's adjusted now as well. The PR to nextcloud-docker-dev adds host.docker.internal to the proxy container, so no longer needed to fiddle around with IPs.

@mejo- mejo- force-pushed the feat/vite_serve branch 2 times, most recently from 8219fa3 to 15c5182 Compare December 16, 2024 11:23
@mejo- mejo- marked this pull request as ready for review December 16, 2024 11:23
@mejo- mejo- requested a review from max-nextcloud as a code owner December 16, 2024 11:23
@mejo-
Copy link
Member Author

mejo- commented Dec 16, 2024

Unfortunately the approach to make vite serve text at / and rewrite the URLs accordingly didn't work out well. I reverted to the earlier approach and adjusted the docs. This PR is ready to review now.

@mejo- mejo- requested a review from juliusknorr December 16, 2024 11:25
Copy link

codecov bot commented Dec 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 46.86%. Comparing base (2459707) to head (1ba2f4b).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6765   +/-   ##
=======================================
  Coverage   46.86%   46.86%           
=======================================
  Files         747      746    -1     
  Lines       34012    34010    -2     
  Branches     1240     1239    -1     
=======================================
  Hits        15940    15940           
+ Misses      17451    17450    -1     
+ Partials      621      620    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Use the same filename for source file and compiled asset.

Signed-off-by: Jonas <[email protected]>
@mejo- mejo- merged commit 570f7a0 into main Dec 16, 2024
67 of 68 checks passed
@mejo- mejo- deleted the feat/vite_serve branch December 16, 2024 14:27
When using [nextcloud-docker-dev](https://github.com/juliusknorr/nextcloud-docker-dev), add the following snippet to `data/nginx/vhost.d/nextcloud.local` and restart the proxy container. You might have to replace `/apps/text` with e.g. `/apps-extra/text` depending on where the text app resides in your dev setup.
```
location /apps/text/ {
proxy_pass http://host.docker.internal:5173/apps/text;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

proxy_pass http://host.docker.internal:5173/apps/text/;

I needed this traling slash to make it work 🤷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ☑️ Done
Development

Successfully merging this pull request may close these issues.

Build performance with vite
3 participants