-
Notifications
You must be signed in to change notification settings - Fork 428
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 support react-scripts more than 2.1.2 version #344
Conversation
@vdfor |
Maybe CRACO is broken too, haha! :-( I think it's broken because CRA 2.1.2 merged facebook/create-react-app#5722
I checked CRACO, it's using old approach too! Can someone confirm this? |
@vdfor |
If some people want to confirm this PR works I will merge. |
const webpackConfigPath = paths.scriptVersion + "/config/webpack.config.prod"; | ||
const scriptPkg = require(paths.scriptVersion + "/package.json"); | ||
|
||
const isOldScript = !(scriptPkg && scriptPkg.version >= '2.1.2'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I doubt this version comparison works for all semver features 😕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to use the module to compare version
https://github.com/omichelsen/compare-versions
or
https://github.com/npm/node-semver
|
||
const isOldScript = !(scriptPkg && scriptPkg.version >= '2.1.2'); | ||
|
||
const webpackConfigPath = paths.scriptVersion + isOldScript ? "/config/webpack.config.prod" : "/config/webpack.config"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather use a try/catch
block and require.resolve
to detect which config file is available
dilanx/craco#62 |
|
||
const isOldScript = !(scriptPkg && scriptPkg.version >= '2.1.2'); | ||
|
||
const webpackConfigPath = paths.scriptVersion + isOldScript ? "/config/webpack.config.prod" : "/config/webpack.config"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now it doesn't work :(
brackets are missing. should be
const webpackConfigPath = paths.scriptVersion + (isOldScript ? "/config/webpack.config.prod" : "/config/webpack.config");
or like this
const webpackConfigPathSuffix = isOldScript ? ".prod" : "";
const webpackConfigPath = paths.scriptVersion + "/config/webpack.config" + webpackConfigPathSuffix;
and the same for start
CRACO is broken too, switch to https://github.com/rescripts/rescripts |
Closing this as this one has been merged. |
No description provided.