-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,16 @@ process.env.NODE_ENV = 'production'; | |
|
||
const paths = require('./utils/paths'); | ||
const overrides = require('../config-overrides'); | ||
const webpackConfigPath = paths.scriptVersion + "/config/webpack.config.prod"; | ||
const scriptPkg = require(paths.scriptVersion + "/package.json"); | ||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. I would rather use a There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
||
// load original config | ||
const webpackConfig = require(webpackConfigPath); | ||
// override config in memory | ||
require.cache[require.resolve(webpackConfigPath)].exports = | ||
overrides.webpack(webpackConfig, process.env.NODE_ENV); | ||
isOldScript ? overrides.webpack(webpackConfig, process.env.NODE_ENV) : (env) => overrides.webpack(webpackConfig(env), env); | ||
// run original script | ||
require(paths.scriptVersion + '/scripts/build'); |
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