Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react-app-rewired breaks w/ react-scripts 2.1.2 #343

Closed
bugzpodder opened this issue Dec 23, 2018 · 12 comments · Fixed by #346
Closed

react-app-rewired breaks w/ react-scripts 2.1.2 #343

bugzpodder opened this issue Dec 23, 2018 · 12 comments · Fixed by #346

Comments

@bugzpodder
Copy link

react-scripts 2.1.2+ has only one webpack.config.js now (prod + dev are configs are combined into one). This breaks react-app-rewired because it looks for webpack.config.prod.js

I know this module is no longer maintained, but up to this point (react-scripts 2.1.1 or earlier) it still allows you to manually modify parts of the config without issues. Just a heads up for anymore who may ran into this issue.

@bugzpodder
Copy link
Author

https://github.com/arackaf/customize-cra seems to rely on this package as well

@xuanhoa88
Copy link

xuanhoa88 commented Dec 25, 2018

I can resolve this issue with update source code for 2 files as below:

start.js

process.env.NODE_ENV = process.env.NODE_ENV || "development";

const paths = require("./utils/paths");
const overrides = require('../config-overrides');
const webpackConfigPath = paths.scriptVersion + "/config/webpack.config";
const devServerConfigPath = paths.scriptVersion + "/config/webpackDevServer.config.js";

// load original configs
const configFactory = require(webpackConfigPath);
const devServerConfig = require(devServerConfigPath);

// override config in memory
require.cache[require.resolve(webpackConfigPath)].exports =
  (NODE_ENV) => overrides.webpack(configFactory(NODE_ENV), process.env.NODE_ENV || NODE_ENV);

require.cache[require.resolve(devServerConfigPath)].exports =
  overrides.devServer(devServerConfig, process.env.NODE_ENV);

// run original script
require(paths.scriptVersion + "/scripts/start");

build.js

process.env.NODE_ENV = 'production';

const paths = require('./utils/paths');
const overrides = require('../config-overrides');
const webpackConfigPath = paths.scriptVersion + "/config/webpack.config";

// load original config
const configFactory = require(webpackConfigPath);

// override config in memory
require.cache[require.resolve(webpackConfigPath)].exports =
  (NODE_ENV) => overrides.webpack(configFactory(NODE_ENV), process.env.NODE_ENV || NODE_ENV);

// run original script
require(paths.scriptVersion + '/scripts/build');

@jihchi jihchi mentioned this issue Dec 25, 2018
@vdfor
Copy link

vdfor commented Dec 25, 2018

#344

@AndyOGo
Copy link

AndyOGo commented Dec 26, 2018

@bugzpodder
Just switch to craco JS (it's crafted for CRA V2) Well as said below, it's broken too...
https://github.com/sharegate/craco

@hsz
Copy link
Contributor

hsz commented Dec 27, 2018

@AndyOGo Currently also broken with CRA v2.1.2: dilanx/craco#61

@flyingcrp
Copy link

@AndyOGo Currently also broken with CRA v2.1.2: sharegate/craco#61

yep, i got it in CRA V2.1.2 .

is there some solutions?

image

@hsz
Copy link
Contributor

hsz commented Dec 29, 2018

@alejandronanez simply stick to the v2.1.1 and wait for fix. There is no other workaround possible here.

@flyingcrp
Copy link

oh...god.
in CRA 2.1.3 also got this problem .:(

@AndyOGo
Copy link

AndyOGo commented Jan 5, 2019

seems rescripts is working:
https://github.com/rescripts/rescripts

timarney pushed a commit that referenced this issue Jan 6, 2019
* react-app-rewired support react-scripts more than 2.1.2 version

* Fix for CRA 2.1.2 #343, builds on #344

* See about using node 6 and 8 in CI
@timarney timarney reopened this Jan 6, 2019
@timarney
Copy link
Owner

timarney commented Jan 6, 2019

#346 is now merged.

You can test using

Next steps:

  • Remove the built in rewires i.e. getLoader
  • Update the docs
  • Release a major version with the changes

@timarney
Copy link
Owner

timarney commented Jan 6, 2019

Just pushed 2.0.1 to npm thanks @tiffon for the PR + testing.

@kumarEduca
Copy link

Thank you so much Tim and @tiffon for quick resolution. Life saver for me !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants