Replies: 5 comments 9 replies
-
Vite does not load |
Beta Was this translation helpful? Give feedback.
-
For some reason, the correct configuration for HMR in Docker is now
I wish I knew what happened to break all my apps, but this fixed it |
Beta Was this translation helpful? Give feedback.
-
TL;DR Vite hot module reloading does NOT work consistently in Docker as of 3/1/2024. Some |
Beta Was this translation helpful? Give feedback.
-
I am facing the same issue, last week HMR stopped working. |
Beta Was this translation helpful? Give feedback.
-
I'm facing a similar issue for the past few weeks. When I change only one file at a time, everything works fine. But when I change two or more files and save them together, only one file updates in the UI with HMR. Also, refreshing the Page without cache doesn't resolve the issue. I have to change the incorrect files again to get them updated. However, inside the Docker container, all files are changed, and their update timestamps are correct. Interestingly, if I use Vite's local server without Docker, I don't encounter these issues, so it's definitely related to Docker. I'm not sure if |
Beta Was this translation helpful? Give feedback.
-
Describe the bug
Today our working configuration for hot module reloading stopped working.
We have a Vite app running in a Docker container. When a src file changes, the app does not reload.
Reproduction
http://example.com/DOCKER_ISSUE
Steps to reproduce
Run
npm create vite@latest
Place the scaffolded contents in a subdirectory called
app
.Add the below
docker-compose.local.yaml
in the root directory.Add the below
vite.config.jsx
to theapp
directory.vite.config.jsx
Place the following
Dockerfile.local
inapp/Dockerfiles
Run
docker-compose -f docker-compose.local.yaml build; docker-compose -f docker-compose.local.yaml up
Changes to the source code are not hot-reloaded
System Info
✔ Container vite-project-app-1 Recreated 0.1s
Attaching to app-1
app-1 |
app-1 | > [email protected] start
app-1 | > vite --debug --host
app-1 |
app-1 | 2024-03-05T23:12:20.551Z vite:config no config file found.
app-1 | 2024-03-05T23:12:20.559Z vite:config using resolved config: {
app-1 | root: '/usr/src/app',
app-1 | base: '/',
app-1 | mode: 'development',
app-1 | configFile: undefined,
app-1 | logLevel: undefined,
app-1 | clearScreen: undefined,
app-1 | optimizeDeps: {
app-1 | holdUntilCrawlEnd: true,
app-1 | force: undefined,
app-1 | esbuildOptions: { preserveSymlinks: false }
app-1 | },
app-1 | server: {
app-1 | preTransformRequests: true,
app-1 | host: true,
app-1 | sourcemapIgnoreList: [Function: isInNodeModules$1],
app-1 | middlewareMode: false,
app-1 | fs: {
app-1 | strict: true,
app-1 | allow: [Array],
app-1 | deny: [Array],
app-1 | cachedChecks: undefined
app-1 | }
app-1 | },
app-1 | configFileDependencies: [],
app-1 | inlineConfig: {
app-1 | root: undefined,
app-1 | base: undefined,
app-1 | mode: undefined,
app-1 | configFile: undefined,
app-1 | logLevel: undefined,
app-1 | clearScreen: undefined,
app-1 | optimizeDeps: { force: undefined },
app-1 | server: { host: true }
app-1 | },
app-1 | rawBase: '/',
app-1 | resolve: {
app-1 | mainFields: [ 'browser', 'module', 'jsnext:main', 'jsnext' ],
app-1 | conditions: [],
app-1 | extensions: [
app-1 | '.mjs', '.js',
app-1 | '.mts', '.ts',
app-1 | '.jsx', '.tsx',
app-1 | '.json'
app-1 | ],
app-1 | dedupe: [],
app-1 | preserveSymlinks: false,
app-1 | alias: [ [Object], [Object] ]
app-1 | },
app-1 | publicDir: '/usr/src/app/public',
app-1 | cacheDir: '/usr/src/app/node_modules/.vite',
app-1 | command: 'serve',
app-1 | ssr: {
app-1 | target: 'node',
app-1 | optimizeDeps: { noDiscovery: true, esbuildOptions: [Object] }
app-1 | },
app-1 | isWorker: false,
app-1 | mainConfig: null,
app-1 | isProduction: false,
app-1 | plugins: [
app-1 | 'vite:optimized-deps',
app-1 | 'vite:watch-package-data',
app-1 | 'vite:pre-alias',
app-1 | 'alias',
app-1 | 'vite:modulepreload-polyfill',
app-1 | 'vite:resolve',
app-1 | 'vite:html-inline-proxy',
app-1 | 'vite:css',
app-1 | 'vite:esbuild',
app-1 | 'vite:json',
app-1 | 'vite:wasm-helper',
app-1 | 'vite:worker',
app-1 | 'vite:asset',
app-1 | 'vite:wasm-fallback',
app-1 | 'vite:define',
app-1 | 'vite:css-post',
app-1 | 'vite:worker-import-meta-url',
app-1 | 'vite:asset-import-meta-url',
app-1 | 'vite:dynamic-import-vars',
app-1 | 'vite:import-glob',
app-1 | 'vite:client-inject',
app-1 | 'vite:css-analysis',
app-1 | 'vite:import-analysis'
app-1 | ],
app-1 | css: { lightningcss: undefined },
app-1 | esbuild: { jsxDev: true },
app-1 | build: {
app-1 | target: [ 'es2020', 'edge88', 'firefox78', 'chrome87', 'safari14' ],
app-1 | cssTarget: [ 'es2020', 'edge88', 'firefox78', 'chrome87', 'safari14' ],
app-1 | outDir: 'dist',
app-1 | assetsDir: 'assets',
app-1 | assetsInlineLimit: 4096,
app-1 | cssCodeSplit: true,
app-1 | sourcemap: false,
app-1 | rollupOptions: {},
app-1 | minify: 'esbuild',
app-1 | terserOptions: {},
app-1 | write: true,
app-1 | emptyOutDir: null,
app-1 | copyPublicDir: true,
app-1 | manifest: false,
app-1 | lib: false,
app-1 | ssr: false,
app-1 | ssrManifest: false,
app-1 | ssrEmitAssets: false,
app-1 | reportCompressedSize: true,
app-1 | chunkSizeWarningLimit: 500,
app-1 | watch: null,
app-1 | commonjsOptions: { include: [Array], extensions: [Array] },
app-1 | dynamicImportVarsOptions: { warnOnError: true, exclude: [Array] },
app-1 | modulePreload: { polyfill: true },
app-1 | cssMinify: true
app-1 | },
app-1 | preview: {
app-1 | port: undefined,
app-1 | strictPort: undefined,
app-1 | host: true,
app-1 | https: undefined,
app-1 | open: undefined,
app-1 | proxy: undefined,
app-1 | cors: undefined,
app-1 | headers: undefined
app-1 | },
app-1 | envDir: '/usr/src/app',
app-1 | env: {
app-1 | VITE_APP_DJANGO_HOST: 'http://localhost:8000',
app-1 | BASE_URL: '/',
app-1 | MODE: 'development',
app-1 | DEV: true,
app-1 | PROD: false
app-1 | },
app-1 | assetsInclude: [Function: assetsInclude],
app-1 | logger: {
app-1 | hasWarned: false,
app-1 | info: [Function: info],
app-1 | warn: [Function: warn],
app-1 | warnOnce: [Function: warnOnce],
app-1 | error: [Function: error],
app-1 | clearScreen: [Function: clearScreen],
app-1 | hasErrorLogged: [Function: hasErrorLogged]
app-1 | },
app-1 | packageCache: Map(1) {
app-1 | 'fnpd_/usr/src/app' => {
app-1 | dir: '/usr/src/app',
app-1 | data: [Object],
app-1 | hasSideEffects: [Function: hasSideEffects],
app-1 | webResolvedImports: {},
app-1 | nodeResolvedImports: {},
app-1 | setResolvedCache: [Function: setResolvedCache],
app-1 | getResolvedCache: [Function: getResolvedCache]
app-1 | },
app-1 | set: [Function (anonymous)]
app-1 | },
app-1 | createResolver: [Function: createResolver],
app-1 | worker: { format: 'iife', plugins: '() => plugins', rollupOptions: {} },
app-1 | appType: 'spa',
app-1 | experimental: { importGlobRestoreExtension: false, hmrPartialAccept: false },
app-1 | getSortedPlugins: [Function: getSortedPlugins],
app-1 | getSortedPluginHooks: [Function: getSortedPluginHooks]
app-1 | }
app-1 | 2024-03-05T23:12:20.571Z vite:deps removing old cache dir /usr/src/app/node_modules/.vite/deps
app-1 | 2024-03-05T23:12:20.574Z vite:deps scanning for dependencies...
app-1 |
app-1 | VITE v5.1.5 ready in 117 ms
app-1 |
app-1 | ➜ Local: http://localhost:5173/
app-1 | ➜ Network: http://172.23.0.2:5173/
app-1 | 2024-03-05T23:12:20.591Z vite:deps Crawling dependencies using entries:
app-1 | /usr/src/app/index.html
app-1 | 2024-03-05T23:12:20.608Z vite:resolve 0.19ms /main.js -> /usr/src/app/main.js
app-1 | 2024-03-05T23:12:20.613Z vite:resolve 1.92ms ./src/counter.js -> /usr/src/app/src/counter.js
app-1 | 2024-03-05T23:12:20.621Z vite:deps Scan completed in 46.78ms: no dependencies found
app-1 | 2024-03-05T23:12:20.622Z vite:deps creating package.json in /usr/src/app/node_modules/.vite/deps_temp_97945337
Beta Was this translation helpful? Give feedback.
All reactions