question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

All styles from layouts and pages being loaded in dev mode – Nuxt 3

See original GitHub issue

Versions

  • nuxt: nuxt3@3.0.0-27276275.abfbd2f
  • node: 14.17.0

Reproduction

In short, the issue is that CSS from different pages & layouts is included on all pages, resulting in pages being styled incorrectly. This only happens in dev mode in Nuxt 3 – when building for prod, the CSS is included as expected.

I’ve set up a repo that shows the issue (and goes through the expected and actual behaviour).

A similar issue was reported for Nuxt 2, where one of the team said that the issue would be looked at for Nuxt 3 – which is why I set up this test repo, as we’re seeing this issue on our project.

Steps to reproduce

  • Check out this repo
  • Go to the nuxt3-app folder in command line, install dependencies (yarn) and run yarn dev to reproduce the issue.
  • The test site has 4 pages – /, /search, /menu and /checkout – and the expected/actual results are documented in the README of the repo.

What is Expected?

When rendering a page, styles from irrelevant layouts and other pages do not also load on the page.

What is actually happening?

Currently, in dev mode, it looks like all styles from all layouts and pages are included in the head of each page, resulting in issues with the page displaying styles that aren’t intended for the current page.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:6
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
manniLcommented, Oct 8, 2022

@danielroe Should we transfer this issue to the https://github.com/nuxt/framework repo?

3reactions
kosmelncommented, Apr 1, 2022

We stumbled upon the very same issue. It really looks like a blocker for development team. Can anybody provide an actual status update on this? Or a temp workaround till the fix is in place? Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration - Nuxt
The css Property ... Nuxt lets you define the CSS files/modules/libraries you want to set globally (included in every page). In case you...
Read more >
layouts/ · Nuxt Directory Structure
Nuxt provides a customizable layouts framework you can use throughout your application, ideal for extracting common UI or code patterns into reusable layout...
Read more >
Nuxt 3 Crash Course #6 - Layouts - YouTube
In this Nuxt lesson, you'll lear how to make layout files for your pages. Watch the whole course now (without ads) on Net...
Read more >
Nuxt 3 Beta: What's New and How to Get Started - SitePoint
Functions in server/middleware/ load automatically and run in every request — which is much similar than how Express works. Apps can be deployed ......
Read more >
Configuration - NuxtJS
In order to be aware of code style errors, you may want to run ESLint on every build in the dev environment. nuxt.config.js...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found