Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"webpackHotUpdate is not defined" error when using extractCSS option #43

Open
Luffyyy opened this issue Oct 21, 2021 · 5 comments
Open
Labels
bug Something isn't working

Comments

@Luffyyy
Copy link

Luffyyy commented Oct 21, 2021

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 Luffyyy added bridge bug Something isn't working labels Oct 21, 2021
@ThomasBerne
Copy link

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.

@danielh-official
Copy link

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.

@enkot
Copy link

enkot commented Aug 18, 2022

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

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

@dargmuesli
Copy link
Member

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

@Suniron
Copy link

Suniron commented Nov 10, 2023

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,
              },
            },
          },
        },
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants