From 0ac0b5653da9ad5ddbdeeca851ad8741a137d9bd Mon Sep 17 00:00:00 2001 From: hakobpogh Date: Mon, 24 Aug 2020 15:26:50 +0400 Subject: [PATCH] [add] adjust webpack config feature --- packages/react-scripts/config/webpack.config.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/react-scripts/config/webpack.config.js b/packages/react-scripts/config/webpack.config.js index 502736ead11..6a0c7e16bbe 100644 --- a/packages/react-scripts/config/webpack.config.js +++ b/packages/react-scripts/config/webpack.config.js @@ -165,7 +165,7 @@ module.exports = function (webpackEnv) { return loaders; }; - return { + const config = { mode: isEnvProduction ? 'production' : isEnvDevelopment && 'development', // Stop compilation early in production bail: isEnvProduction, @@ -790,4 +790,12 @@ module.exports = function (webpackEnv) { // our own hints via the FileSizeReporter performance: false, }; + + if (appPackageJson.adjustWebpackConfig) { + const adjustWebpackConfigPath = path.join(path.dirname(paths.appPackageJson), appPackageJson.adjustWebpackConfig) + const adjustWebpackConfig = require(adjustWebpackConfigPath); + return adjustWebpackConfig(config); + } + + return config; };