Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

create-react-app 2.1.2 has a breaking change for webpack config file location #18

Closed
wants to merge 1 commit into from

Conversation

kaltepeter
Copy link

create-react-app 2.1.2 makes a breaking changes merging the webpack paths into a single config. see: facebook/create-react-app#5722

This fixes the breaking change to load the single webpack.config.js with 'development' as the environment to load.

I don't have react apps with ejected config so that path is untested.

I have tested non-ejected create-react-app and it runs again.

to test locally: npm i -D github:kaltepeter/cra-build-watch#update-webpack-paths

@Nargonath Nargonath self-assigned this Dec 26, 2018
@Nargonath Nargonath added the enhancement New feature or request label Dec 26, 2018
Copy link
Owner

@Nargonath Nargonath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution @kaltepeter. To test with an ejected project this is really easy, just eject a bare new CRA project so you can see how the files are laid out (that's how I did previously). Let me know if you need help with that.

@@ -14,8 +14,8 @@ const { getReactScriptsVersion, isEjected } = require('../utils');
const paths = isEjected ? importCwd('./config/paths') : importCwd('react-scripts/config/paths');
const webpack = importCwd('webpack');
const config = isEjected
? importCwd('./config/webpack.config.dev')
: importCwd('react-scripts/config/webpack.config.dev');
? importCwd('./config/webpack.config')('development')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid it will be a bit more complicated than that. If we do that, we break the backward compatibility with react-scripts previous version. You need to use the react-scripts version that are available to you higher up:

const { getReactScriptsVersion, isEjected } = require('../utils');
to use the previous webpack.config file path or your new version. To see an example of how it is used:
if (major >= 2) {

We also need to check that the array indexes have not changed and remain the same in the second line of code I linked.

@@ -11,7 +11,7 @@ const DEFAULT_VERSION = {
patch: 4,
};

exports.isEjected = fs.pathExistsSync(path.join(process.cwd(), 'config/webpack.config.dev.js'));
exports.isEjected = fs.pathExistsSync(path.join(process.cwd(), 'config/webpack.config.js'));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here than above.

@Nargonath
Copy link
Owner

Closed in favor of already merged: #20

@Nargonath Nargonath closed this Jan 10, 2019
@Nargonath Nargonath added the duplicate This issue or pull request already exists label Jan 10, 2019
@kaltepeter kaltepeter deleted the update-webpack-paths branch May 8, 2020 14:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants