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.

Built-In Global CSS Support Not working!

See original GitHub issue

What version of Next.js are you using?

11.1.2 Tested in canary to

What version of Node.js are you using?

14.17.6

What browser are you using?

Chrome 93.0.4577.82

What operating system are you using?

Windows

How are you deploying your application?

Other platform

Describe the Bug

Global CSS import in custom _app.js with either CSS or SASS cannot be importet

Even if you have a nextJS config 2 with sass options and added paths still same error

(node:13500) [DEP_WEBPACK_MODULE_ISSUER] DeprecationWarning: Module.issuer: Use new ModuleGraph API
(Use `node --trace-deprecation ...` to show where the warning was created)
error - ./public/css/globals.scss
Global CSS cannot be imported from files other than your Custom <App>. Due to the Global nature of stylesheets, and to avoid conflicts, Please move all first-party global CSS imports to pages/_app.js. Or convert the import to Component-Level CSS (CSS Modules).
Read more: https://nextjs.org/docs/messages/css-global
Location: pages\_app.js

Expected Behavior

It should import the css or scss like every other time import the css or scss like normal but it fails completely

To Reproduce

2 ways to do it manually or with npx create-next-app

Manually:

  1. Create a new project with npm init -y in a test folder
  2. Install NextJS npm install -P next react react-dom
  3. Create the pages folder and create an index.js and _app.js file
  4. In the Root of the project Create a scss file styles.scss
  5. In the index.js file just simply create a hello world like so
export default function Index() {
  return 'Hello World!';
}
  1. In the _app.js use this:
import '../styles.scss'

export default function MyApp({ Component, pageProps }) {
  return <Component {...pageProps} />
}
  1. In the styles.scss use this:
body {
  background-color: slateblue;
}
  1. Last open a console and run the dev application npm run dev

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Melonendkcommented, Sep 17, 2021

Upon further investigation i on my own pc at home it works fine now, maybe it was some caching even tho i cleared it to test. but anyway thanks for the response Keep up the great work! 😃

0reactions
balazsorban44commented, Jan 27, 2022

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Warning: Built-in CSS support is being disabled due to custom ...
I've tried to explain most common cases. Next.js doesn't support importing CSS in components unless it's a CSS Module . If you still...
Read more >
Basic Features: Built-in CSS Support - Next.js
Next.js supports including CSS files as Global CSS or CSS Modules, using `styled-jsx` for CSS-in-JS, or any other CSS-in-JS solution! Learn more here....
Read more >
Global CSS cannot be imported from within node_modules.
I can't import a css file from a node_modules 3rd party library as described here (https://nextjs.org/docs/basic-features/built-in-css-support# ...
Read more >
Next.js: Global CSS cannot be imported from files other than ...
When migrating to Next.js 9+, I was running into an issue where I could not import global styles from any file other than...
Read more >
Built-in CSS Support - Gatsby
Global CSS. CSS files with global styles like typography and colors are typically imported into the site's gatsby-browser.js file.
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