[@next/storybook] _app.js must be imported within stories for global css to apply
See original GitHub issueBug 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
- Check out this reproduction repo
- 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:
- Created 3 years ago
- Reactions:3
- Comments:11 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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
Can you assign this to me @nfroidure ?