vite icon indicating copy to clipboard operation
vite copied to clipboard

Not possible to disable HMR

Open thebrownfox opened this issue 4 years ago • 7 comments

Versions

nuxt-vite: 0.0.28 nuxt: 2.15.2

Description

There's ws call even when there's hmr:false. This makes it hard to deploy behind reverse proxy with redirects. Tried everything (setting port and path, proxy, etc) and it didn't work for me. It would be better to turn it off completely. nuxt.config.js

 vite: {
        server: {
            hmr: false,
        },
    },

thebrownfox avatar Mar 02 '21 17:03 thebrownfox

Adding option makes sense to disable ws/hmr. But i think toy shouldn't deploy development mode of nuxt to prod 😅

pi0 avatar Mar 02 '21 17:03 pi0

It's not prod, but dev server. I just need devtools but nuxt forces production env on nuxt build.

I've tried to take a look into source and noticed you need workaround to turn off HMR in server.ts.

thebrownfox avatar Mar 02 '21 17:03 thebrownfox

Also related to HMR: https://github.com/vitejs/vite/pull/2338

atinux avatar Mar 03 '21 08:03 atinux

@Atinux I think your reference is related to #47

pi0 avatar Mar 03 '21 08:03 pi0

@Atinux I see. There's middleware option enabled. Haven't realized even though docs mention it 😅 https://github.com/nuxt/vite/blob/04d01edfa9d5eb94e76736ae95a6394bba375a06/src/client.ts#L38

thebrownfox avatar Mar 03 '21 08:03 thebrownfox

Some problem Screen Shot 2021-03-04 at 08 04 15

productdevbook avatar Mar 04 '21 05:03 productdevbook

In my tests, this does disable HMR, even in middlewareMode:

  vite: {
    server: {
      hmr: false
    }
  }

What it does not do is disable the Vite websocket server, which isn't really a possibility for nuxt-vite to do. Opened https://github.com/vitejs/vite/pull/2474 for discussion.

danielroe avatar Mar 11 '21 14:03 danielroe