Built-In Global CSS Support Not working!
See original GitHub issueWhat 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:
- Create a new project with
npm init -y
in a test folder - Install NextJS
npm install -P next react react-dom
- Create the pages folder and create an
index.js
and_app.js
file - In the Root of the project Create a scss file
styles.scss
- In the
index.js
file just simply create a hello world like so
export default function Index() {
return 'Hello World!';
}
- In the
_app.js
use this:
import '../styles.scss'
export default function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />
}
- In the
styles.scss
use this:
body {
background-color: slateblue;
}
- Last open a console and run the dev application
npm run dev
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (5 by maintainers)
Top 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 >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
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! 😃
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.