-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
App Version #2466
Comments
I'm open to allowing package.json; we discussed this on some other issue but I'm not sure which. |
I have done the similar use case by adding + "build": "REACT_APP_VERSION=$(node -pe 'require(\"./package.json\").version') react-scripts build", Also, you can set it to a constant while developing/testing.
|
As mentioned above, setting an environment variable in
The only problem there is when you need
But the problem there is windows won't execute the command substitution The only way i've figured out how to do this cross-platform is to hard-code the version info in
This would give you access to your version number via To me, a clearer, more straightforward approach that would work across platforms would be to enable support for importing // in package.json
"version": "1.0.0"
// in index.js
import packageJson from '../package.json';
console.log(packageJson.version); // "1.0.0" |
Just learned this little trick: you can use // in package.json
"scripts": {
"start": "cross-env REACT_APP_VERSION=$npm_package_version react-scripts start"
} This will make the current value of If you're just targeting Mac, no need for // in package.json
"scripts": {
"start": "REACT_APP_VERSION=$npm_package_version react-scripts start"
} |
FTR: the PR is merged, so |
Awesome! @Aprillion Works great, just tested it I was having to do it like this before:
|
BEWARE: |
Since #3387 has been merged (available in 1.1.0), and following @jimniels awesome discovery, the version (and many other npm config params) can now be accessed from the // .env
REACT_APP_VERSION=$npm_package_version
REACT_APP_NAME=$npm_package_name |
can this be extended to include "homepage"? so that we can use it as the base url for routing and ajax calls, etc |
@AhmedSayed77 use |
Hi,
I'm looking for a way to inject an app version, so it could be used by the app (for analytics, debugging, etc). Usually I use the app's
package.json
, taking advantage of npm version command. But import is only allowed from within src/ as can be seen in ModuleScopePlugin.I wanted to know if there's another solution to this general problem (app versioning), or if the app's
package.json
can just be allowed to be imported by the scope pluginAs a workaround I just created a symlink to
package.json
insrc/
, which is nice, in a way, because you can see the app is dependent on it, but for me it's a common pattern (using the package.json), so maybe it's better just to allow itThe text was updated successfully, but these errors were encountered: