score:5
score:0
You can use grunt-bump to handle your app versioning. As for displaying your app version, refer to Is there a way to get version from package.json in nodejs code?.
score:1
I don't think the answers from @Bertrand P or @VulfCompressor tell the complete picture. I used genversion https://www.npmjs.com/package/genversion. The steps I did were:
npm install genversion --save-dev
- Modify the build script in
package.json
togenversion --es6 src/autobuild_version.js && react-scripts build
(I couldn't figure out a way to import the generated module from thelib
directory as suggested in the genversion documentation so I had to put it in thesrc
directory instead) - In the React app,
import { version } from './autobuild_version'
and use as appropriate - Add
src/autobuild_version.js
to.gitignore
(other source code control tools are available) npm run build
score:2
Once you have a way to bump the version in package.json (e.g. npm version
, as suggested by @bertrand-p), you can then assign the version to an environment variable. For example, in .env
you can set:
REACT_APP_VERSION=$npm_package_version
Then you can access the variable from within your app via process.env.REACT_APP_VERSION
.
See also: https://github.com/facebook/create-react-app/issues/2466#issuecomment-357490359
Source: stackoverflow.com
Related Query
- How to do app versioning in create react app?
- How to create a React app directly in the current folder
- How to create multiple page app using react
- How to not show warnings in Create React App
- How to include custom JS files in to React create app
- How to inject port and host using ENV variable in Create React App Proxy settings?
- How to fix TypeError _interopRequireDefault is not a function in Create React App
- How to use yarn to create a React app project?
- How to change PublicPath for Create React App in Dev Environment
- How to analyze create react app build size and reduce it?
- How to read console.log from a mounted component with Enzyme and Jest in Create React App
- How to import a file into a react app that uses create react app as raw text?
- how to use .env.qa or .env.staging with create react app
- How to make React Create App Production Error Boundary map to source code
- How to create a React App without Create-react-app
- Create react app - how to copy pdf.worker.js file from pdfjs-dist/build to your project's output folder?
- How to create react app without git (skipping git)?
- How to avoid very long paths and use absolute paths within a Create React App project?
- how to config create react app with worker-loader
- How to make a npm package from Create React App /build folder?
- How to remove dead code in Create React App
- How to use Turborepo for an existing react app created with Create React App in order to make it a monorepo?
- How to run eslint in create react app
- How to create and deploy a React App properly?
- How get window values in Tests with Enzyme, Jest + Create React App
- How to create React App including Web3 using create-react-app? I am getting Module not found Error. BREAKING CHANGE: webpack < 5 used
- How to determine the order of css in my create react app build with webpack and customize-cra?
- How to enable absolute imports in Create React App v4
- How create a react app with a specific version using the npx command?
- How to create childElement from server response in a react app
More Query from same tag
- Why child component's render is called when props did not change?
- api.get(...).then(...).catch(...).finally is not a function
- Filtering and sorting React
- Conditional ClassName in Router in React
- Can't increasing the value in front end by react. Data comes from mongodb
- How can I detect if a @lexical/react editor is focused?
- How to call an async function inside a UseEffect() in React?
- I have a many poppers and want the one that is open to close when another one opens
- ReactJS componentwillreceiveprops does not produces correct value
- Create React Context that returns 2 Other Functions Through Context Provider
- How to change the tip text of getFieldDecorator dynamically?
- How to insert a string into an array the same amount of times as the int value from an input?
- Is there react/redux like mapStateToProps way in Vue/Vuex
- PNPM - Starting new project not working as expected
- Trying to map data through props to React Bootstrap Accordion - data not displaying?
- react-datepicker is highlighting previously selected date, as well as current date on open. How do I prevent this?
- How to use a promised function in a react app
- How to access state/redux store in the useEffect's cleanup function?
- React Javascript Undefined Variable
- How to render a react component from a string name
- Search bar, <input/>
- Browserify and Reactify source maps include full local path names
- npm ERR! 401 Unauthorized: @babel/core@7.1.0 when using creating new react app
- How to filter objects by roles array?
- How to loop throough fields in a database and find the empty ones
- Globally imported variables are undefined
- React Executing a method inside a component
- Overwrite initial value from redux-form
- WalletConnect fails to get bundled with vite
- After adding react-router-dom following error is shown by Parcel