Why "Global CSS cannot be Imported from Files Other than your Custom
Next.js version 9.2 introduces a revamp in the way global CSS is handled. Prior to this release, global CSS could be imported from any module. However, this practice resulted in challenges in customizing themes and managing styles.
Solution:
To address this issue, Next.js now requires that all global CSS imports be moved to the pages/_app.js file. This allows developers to centralize and control the global styles without scattering them across multiple files.
Steps to Resolve the Error:
Note: If you need to add styles to specific components or pages, you can utilize the built-in CSS modules feature. This allows you to create scoped styles that are only applied to the specific components or pages where they are imported.
Additional Information:
The above is the detailed content of Why Can't I Import Global CSS from Files Other Than `pages/_app.js` in Next.js 9.2 ?. For more information, please follow other related articles on the PHP Chinese website!