bridge icon indicating copy to clipboard operation
bridge copied to clipboard

"webpackHotUpdate is not defined" error when using extractCSS option

Open Luffyyy opened this issue 3 years ago • 5 comments

Environment


  • Operating System: Linux
  • Node Version: v14.17.6
  • Nuxt Version: 2.16.0-27226092.034b9901
  • Package Manager: Yarn
  • Bundler: Webpack
  • User Config: css, build, buildModules
  • Runtime Modules: -
  • Build Modules: @nuxt/[email protected]

Describe the bug

When you add some css file to the css array and then turn on the build.extractCSS option in the nuxt config then change some template's content, the page will fully reload instead of updating the page itself and in the console you will see the following error: image

Also I won't be surprised if this warning has some relation to this issue image

Note that this bug goes away after you edit the template again. In a different project I had it stick for pretty much forever, though I'm not yet sure what causes it to stick, I'll try to create a minimal reproduction of it too if needed. I'm hoping that if this one is fixed, it might also fix it sticking around.

Reproduction

https://codesandbox.io/s/suspicious-pasteur-ycqi3?file=/pages/index.vue

Additional context

No response

Logs

No response

Luffyyy avatar Oct 21 '21 06:10 Luffyyy

I found a workaround by adding this in nuxt.config.ts:

build: {
    optimization: {
      runtimeChunk: true,
      splitChunks: {
        name: true,
        cacheGroups: {
          styles: {
            name: 'styles',
            test: /.(css|vue)$/,
            chunks: 'all',
            enforce: true
          }
        }
      }
    }
  }

I'm using nuxt bridge.

ThomasBerne avatar Dec 07 '21 13:12 ThomasBerne

I found a workaround by adding this in nuxt.config.ts:

build: {
    optimization: {
      runtimeChunk: true,
      splitChunks: {
        name: true,
        cacheGroups: {
          styles: {
            name: 'styles',
            test: /.(css|vue)$/,
            chunks: 'all',
            enforce: true
          }
        }
      }
    }
  }

I'm using nuxt bridge.

I had the same issue and did this. Worked like a charm.

danielh-official avatar Dec 20 '21 00:12 danielh-official

I also have this issue, but when disable nitro - it works fine:

export default defineNuxtConfig({
  ...
  bridge: {
    nitro: false,
  }
})

enkot avatar Aug 18 '22 18:08 enkot

The workaround creates a single css file, right? So one should note a potential performance decrease.

dargmuesli avatar Aug 23 '22 05:08 dargmuesli

This is the updated config for the recent Nuxt Bridge versions:

{
    build: {
        optimization: {
          splitChunks: {
            cacheGroups: {
              styles: {
                name: 'styles',
                test: /.(css|vue)$/,
                chunks: 'all',
                enforce: true,
              },
            },
          },
        },
    }
}

Suniron avatar Nov 10 '23 09:11 Suniron