From cacfd773530046b04c1b74806ee762d191cc3b82 Mon Sep 17 00:00:00 2001 From: Yang Sun <51345108+ysun62@users.noreply.github.com> Date: Mon, 29 Jun 2020 22:25:02 -0700 Subject: [PATCH] modify global css import error message (#14639) Fixes #14464 --- errors/css-global.md | 2 ++ packages/next/build/webpack/config/blocks/css/messages.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/errors/css-global.md b/errors/css-global.md index 22c4e87c5e78b0..51f70f45f6193c 100644 --- a/errors/css-global.md +++ b/errors/css-global.md @@ -10,6 +10,8 @@ Global CSS cannot be used in files other than your [Custom ``](https://next Relocate all Global CSS imports to your [`pages/_app.js` file](https://nextjs.org/docs/advanced-features/custom-app). +Or, [update your component to use local CSS (Component-Level CSS) via CSS Modules](https://nextjs.org/docs/basic-features/built-in-css-support#adding-component-level-css). This is the preferred approach. + #### Example ```jsx diff --git a/packages/next/build/webpack/config/blocks/css/messages.ts b/packages/next/build/webpack/config/blocks/css/messages.ts index a7e2ed9f0de4a3..fbc2ec5026b5bd 100644 --- a/packages/next/build/webpack/config/blocks/css/messages.ts +++ b/packages/next/build/webpack/config/blocks/css/messages.ts @@ -7,7 +7,7 @@ export function getGlobalImportError(file: string | null) { 'Custom ' )}. Please move all global CSS imports to ${chalk.cyan( file ? file : 'pages/_app.js' - )}.\nRead more: https://err.sh/next.js/css-global` + )}. Or convert the import to Component-Level CSS (CSS Modules).\nRead more: https://err.sh/next.js/css-global` } export function getGlobalModuleImportError() {