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

Flash of unstyled content in generated page when using scss nuxt 3.0.0-rc.12 #15213

Closed
nurRiyad opened this issue Oct 20, 2022 · 15 comments
Closed

Comments

@nurRiyad
Copy link

nurRiyad commented Oct 20, 2022

Environment

package.json

{
  "private": true,
  "scripts": {
    "build": "nuxt build",
    "dev": "HOST=0.0.0.0 nuxt dev",
    "generate": "nuxt generate",
    "preview": "nuxt preview",
    "postinstall": "nuxt prepare"
  },
  "devDependencies": {
    "nuxt": "3.0.0-rc.12",
    "sass": "^1.55.0"
  }
}

nuxt.config.ts

// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
  css: ['@/main.scss'],
  experimental: {
    // Temporary workaround for stackblitz
    writeEarlyHints: false,
  },
});

Reproduction

StackBlitz minimal reproduction link
https://stackblitz.com/edit/github-hywqdd?file=app.vue

Describe the bug

At reload time it shows unstyled pages. But in the dev server, it seems fine. It only appears when I generate the project with
npm run generate and serve with npm run preview

Additional context

In my project, this problem doesn't appear until nuxt3 rc-11.0.0. It only starts appearing after updating my project to nuxt3 rc-12.0.0

Logs

No response

Copy link
Member

This is a regression of the inline styles implementation and you can work around it by setting experimental.inlineSSRStyles to false.

@BlakeB415
Copy link

This is a regression of the inline styles implementation and you can work around it by setting experimental.inlineSSRStyles to false.

This workaround breaks our styling on the initial page load.

@danielroe
Copy link
Member

@BlakeB415 Would you provide a reproduction? 🙏

@kwright02
Copy link

@BlakeB415 Would you provide a reproduction? 🙏

We'll do our best but we're not sure how to. We set the option like you said above and as Blake mentioned it breaks the styling on initial page load. Is there something specific we could do or provide for you?

@danielroe
Copy link
Member

@kwright02 Some info here.

Basically, start with your project and remove as much as you can until the problem can't be reproduced. 🙏

I have a fix for this issue in progress but want to make sure it also solves your situation.

@kwright02
Copy link

Ok, I'll see what I can test, any recommendations for where to start removing from? Or does it really matter?

@danielroe
Copy link
Member

Try to remove as much complexity as possible, as quickly as possible. Start with your app.vue, remove layouts, remove all pages but index page, gradually remove components in that page, etc.

@BlakeB415
Copy link

Try to remove as much complexity as possible, as quickly as possible. Start with your app.vue, remove layouts, remove all pages but index page, gradually remove components in that page, etc.

https://stackblitz.com/edit/github-hywqdd-nehtut?file=components/Test.vue

I've narrowed it down to our use of ClientOnly. Using ClientOnly inside of a component seems to break scoped CSS on SSR when inlineSSRStyles is false. The server and client's data-v-* attributes do not seem to match up when this occurs.

@danielroe
Copy link
Member

Thanks. I appreciate it.

@BlakeB415
Copy link

BlakeB415 commented Oct 23, 2022

Thanks. I appreciate it.

No problem. Also, this only seems to occur with the build and not the dev server.

@monkemedia
Copy link

Oh my god this has taken me hours to resolve since upgrading to rc.12. The unstyled flash was extremely annoying :/ Thankfully experimental: { inlineSSRStyles: false }, fixed it for me. Thank you @danielroe

@codingcn
Copy link

this only seems to occur with the build and not the dev server.

@codingcn
Copy link

codingcn commented Oct 26, 2022

@danielroe when experimental.inlineSSRStyles to false and yarn build

I have 3 <style>

<template>
  <div>
  </div>
</template>

<style lang="scss">
// Valid
</style>

<style lang="scss">
// Invalid
</style>

<style scoped lang="scss">
// Invalid
</style>

@danielroe
Copy link
Member

@codingcn That sounds like #15227.

@manniL
Copy link
Member

manniL commented Nov 5, 2022

Should be resolved via nuxt/framework#8666 - cannot reproduce with rc.13 anymore.

@manniL manniL closed this as completed Nov 5, 2022
@danielroe danielroe added the 3.x label Jan 19, 2023
@danielroe danielroe transferred this issue from nuxt/framework Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants