Skip to content

Commit

Permalink
#267 frontend: disable hmr in dockerized environments
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolkenfarmer committed Jul 11, 2024
1 parent e66f708 commit 7f52a08
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ COPY . .
ENV VITE_RUN_CONFIG=${VITE_RUN_CONFIG}
ENV VITE_SERVER_URL_HTTP=${VITE_SERVER_URL_HTTP}
ENV VITE_SERVER_URL_WS=${VITE_SERVER_URL_WS}
ENV IS_DOCKER=TRUE
ENV PORT=5173
EXPOSE 5173
RUN if [ "$VITE_RUN_CONFIG" = "prod" ]; then npm run build-only; fi
Expand Down
14 changes: 8 additions & 6 deletions frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import {fileURLToPath, URL} from 'node:url'
import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'

function isNotDocker() {
const b = !process.env.IS_DOCKER
console.log('isDocker:', b)
return b
}

// https://vitejs.dev/config/
export default defineConfig({
plugins: [
Expand All @@ -19,11 +25,7 @@ export default defineConfig({
'process.env': process.env
},
server: {
// in order for hot module replacement to not throw an error inside the docker container
// (localhost would resolve to the container and not the host)
hmr: {
host: 'ws://host.docker.internal',
port: 80
}
// we do not need hmr in docker images + default address would not work (host: 'host.docker.internal' would be needed)
hmr: isNotDocker(),
}
})

0 comments on commit 7f52a08

Please sign in to comment.