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.

[@next/storybook] _app.js must be imported within stories for global css to apply

See original GitHub issue

Bug report

Describe the bug

When using the @next/storybook preset, use of global css is possible, but it must be added to _app.js within the pages folder, and then the story utilizing the global css must import _app.js. While this works, it’s an unusual and unintuitive, so I would assume the aim would be to eliminate this pattern.

To Reproduce

  1. Check out this reproduction repo
  2. Note that in order for global css to apply, the _app file must be imported within the story. If it is not imported, css does not apply.

Expected behavior

This is a tough one, I don’t feel like the preset should actually require pages as a folder to be present at all. I’d say the ideal solution for this might be adding some sort of globalCss option to the preset where global css files could be specified - this would remove the dependence on pages, _app.jsx and the _app.jsx import.

System information

  • OS: macOS
  • Version of Next.js: 9.4.4
  • Version of Node.js: 12.13.0

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:3
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Vadorequestcommented, Jan 12, 2021

I didn’t encounter much difficulties regarding global styles, because next v10 allows to have them in a separate file as _app, so it was rather easy to import them in .storybook/preview.js

See PR: https://github.com/UnlyEd/next-right-now/pull/251

0reactions
itsajay1029commented, Dec 25, 2022

Can you assign this to me @nfroidure ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Styling and CSS - Storybook
There are many ways to include CSS in a web application, and correspondingly ... To use your CSS in all stories, you import...
Read more >
Import Global Stylesheets for all Stories in preview.js
In this lesson, we configure Storybook to load global stylesheets for all stories. This is a great way to get general CSS into...
Read more >
Next.js Global CSS cannot be imported from files other than ...
Use the built-in Next.js CSS loader (see here) instead of legacy ... Since Next.js 9.2 global CSS must be imported in Custom <App>...
Read more >
[@next/storybook] - incorrectly imported css throws an ...
Bug report Describe the bug When a css file is imported in the wrong ... using next.js normally - something along the lines...
Read more >
The best styling options for Next.js - LogRocket Blog
The styles created in global.css will then apply to your entire application. To do so, this stylesheet can only be imported in _app.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