From 199c7a5340a3cd06f0aa980d07ae1ad23448c508 Mon Sep 17 00:00:00 2001 From: Arthur Agombart Date: Fri, 3 Mar 2023 12:02:39 +0100 Subject: [PATCH] Add DISABLE_CLEAR_CONSOLE feature --- docusaurus/docs/advanced-configuration.md | 1 + packages/react-dev-utils/clearConsole.js | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/docusaurus/docs/advanced-configuration.md b/docusaurus/docs/advanced-configuration.md index a06c6eff6f4..e63f6af6ae4 100644 --- a/docusaurus/docs/advanced-configuration.md +++ b/docusaurus/docs/advanced-configuration.md @@ -30,3 +30,4 @@ You can adjust various development and production settings by setting environmen | ESLINT_NO_DEV_ERRORS | ✅ Used | 🚫 Ignored | When set to `true`, ESLint errors are converted to warnings during development. As a result, ESLint output will no longer appear in the error overlay. | | DISABLE_ESLINT_PLUGIN | ✅ Used | ✅ Used | When set to `true`, [eslint-webpack-plugin](https://github.com/webpack-contrib/eslint-webpack-plugin) will be completely disabled. | | DISABLE_NEW_JSX_TRANSFORM | ✅ Used | ✅ Used | When set to `true`, disables the [new JSX transform](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html) introduced in React 17 and backported to React 16.14.0, 15.7.0, and 0.14.10. New projects will use a version of React that supports this by default but you may need to disable it in existing projects if you can't upgrade React. | +| DISABLE_CLEAR_CONSOLE | ✅ Used | 🚫 Ignored | When set to `true`, disables the automatic `clearConsole` using `start` script and used by the `WebpackDevServerUtils.js`. | diff --git a/packages/react-dev-utils/clearConsole.js b/packages/react-dev-utils/clearConsole.js index 2099a57ec35..6d48fc00f5e 100644 --- a/packages/react-dev-utils/clearConsole.js +++ b/packages/react-dev-utils/clearConsole.js @@ -8,6 +8,13 @@ 'use strict'; function clearConsole() { + if ( + process.env.NODE_ENV === 'development' && + process.env.DISABLE_CLEAR_CONSOLE === 'true' + ) { + return false; + } + process.stdout.write( process.platform === 'win32' ? '\x1B[2J\x1B[0f' : '\x1B[2J\x1B[3J\x1B[H' );