question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Describe the bug

vite and docker dont seem to work well together every time i develop with both the browser reloads every minute. The browser reloads up to five time per initial load . Also the server crashes at random times during development .

Reproduction

https://github.com/louiss0/vue-2-template

System Info

docker-desktop 3.35

Used Package Manager

npm

Logs

No response

Validations

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:32 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
akauppicommented, Aug 1, 2021

@louiss0 's description maybe needs some editing, to be reproducible.

I’m also setting up Vite HMR with Docker Compose. The part where it still fails is HMR - I just don’t get any changes to the browser, if Vite is being run under Docker. If I run it natively, HMR works like magic.

This issue: Vite hmr does not work in Docker was specifically about HMR but is now closed.

Want to help solving these issues. My work is currently uncommitted, but will be available and reproducible soon.

4reactions
JosephusPayecommented, Dec 1, 2021

I had the same problem and was able to fix it by setting a custom HMR port and exposing that port from the docker container.

  • Set Vite’s server.hmr.port config option to the port you want to use for HMR:
export default defineConfig({
  server: {
    hmr: {
      port: 3010,
    },
  },
  // other options...
})
  • Expose the HMR port when running the docker container: (here I’m using docker-compose)
docker-compose run \
  -p 3000:3000 \       # my dev server port (not needed if you're not using port 3000)
  -p 3010:3010 \       # the HMR port
  webservice \
  yarn dev
Read more comments on GitHub >

github_iconTop Results From Across the Web

Step By Step Guide To Dockerize React App Created Using Vite
In this post, you'll learn how to dockerize your react app created using the Vite tool for the development environment Docker is a...
Read more >
Vite.js Docker Dev - GitHub
Vite.js Docker Dev uses the venerable make command to automate setup and access to the Docker containers used. See the Using Make &...
Read more >
Starting up a new Vue 3 project with Vite and Docker
I'm enjoying new Vue 3 script setup syntax and blazing fast hot-reload using Vite. And as I'm using Docker containers for my development ......
Read more >
vue.js - running a vite dev server inside a docker container
I have a Vue-cli app that I'm trying to convert to vite. I am using Docker to run the server. I looked at...
Read more >
Docker - vite-plugin-ssr
Docker. In general, a vite-plugin-ssr app is just a Node.js server, so we can use any Node.js Docker container. Build. If we build...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found