From 9b967e06f5df1e8ae2c5b13d5c7f7170b069f5bc Mon Sep 17 00:00:00 2001 From: Lachlan Miller Date: Thu, 10 Feb 2022 16:26:20 +1000 Subject: [PATCH] fix: set correct default when using react-scripts plugin (#20141) --- npm/react/examples/react-scripts/cypress/plugins/index.js | 2 +- .../react-scripts/findReactScriptsWebpackConfig.js | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/npm/react/examples/react-scripts/cypress/plugins/index.js b/npm/react/examples/react-scripts/cypress/plugins/index.js index 33bce3362b..df575d3a87 100644 --- a/npm/react/examples/react-scripts/cypress/plugins/index.js +++ b/npm/react/examples/react-scripts/cypress/plugins/index.js @@ -8,7 +8,7 @@ const devServer = require('@cypress/react/plugins/react-scripts') * @type {Cypress.PluginConfig} */ module.exports = (on, config) => { - devServer(on, config) + devServer(on, config, {}) // IMPORTANT to return the config object // with the any changed environment variables diff --git a/npm/react/plugins/react-scripts/findReactScriptsWebpackConfig.js b/npm/react/plugins/react-scripts/findReactScriptsWebpackConfig.js index 48c8402f70..98d9fc7fb0 100644 --- a/npm/react/plugins/react-scripts/findReactScriptsWebpackConfig.js +++ b/npm/react/plugins/react-scripts/findReactScriptsWebpackConfig.js @@ -7,9 +7,11 @@ const { getTranspileFolders } = require('../utils/get-transpile-folders') const { addFolderToBabelLoaderTranspileInPlace } = require('../utils/babel-helpers') const { reactScriptsFiveModifications, isReactScripts5 } = require('../../dist/react-scripts/reactScriptsFive') -module.exports = function findReactScriptsWebpackConfig (config, { - webpackConfigPath, -} = { webpackConfigPath: 'react-scripts/config/webpack.config' }) { +module.exports = function findReactScriptsWebpackConfig (config, devServerOptions) { + const webpackConfigPath = (devServerOptions && devServerOptions.webpackConfigPath) + ? devServerOptions.webpackConfigPath + : 'react-scripts/config/webpack.config' + // this is required because // 1) we use our own HMR and we don't need react-refresh transpiling overhead // 2) it doesn't work with process.env=test @see https://github.com/cypress-io/cypress-realworld-app/pull/832