Thanks to the help of @Bhojendra Rauniyar I got this solution:
- Add this line to
- Run this 3 commands:
REACTBUILDVERSION=$(date +%Y-%m-%d)-$(date +%T) sed -i -- 's/%REACTBUILDVERSION%/'$REACTBUILDVERSION'/g' build/index.html echo React Build Version = $REACTBUILDVERSION
To make it comfortable, these 3 commands can be added to the build in
Original build in
"build": "react-scripts build",
NEW build in
"build": "react-scripts build && REACTBUILDVERSION=$(date +%Y-%m-%d)-$(date +%T) && sed -i -- 's/%REACTBUILDVERSION%/'$REACTBUILDVERSION'/g' build/index.html && echo React Build Version = $REACTBUILDVERSION",
After the build you can see this meta tag in the
You can also add a version key pair to your package.json file
"version": "1.0.0" and then you can read it anywhere in your code as follows
let packageJson = require('./package.json')
packageJson.version should give you access to the version that is set in the package.json file
a similar thing happens when the version is placed in
I follow the following approach (will add git branch name in the version):
# First add '<!-- version: %VERSION% -->' to your public/index.html file $ yarn run build # npm run build (if using npm) $ VERSION=`git rev-parse --abbrev-ref HEAD` $ sed -i -- "s/%VERSION%/$VERSION/g" build/index.html
build/index.html should contain
<!-- version: name-of-the-current-branch -->.
To make it comfortable, you may add version command in package.json:
"build": "VERSION=`git rev-parse --abbrev-ref HEAD` && react-scripts build && sed -i -- 's/%VERSION%/$VERSION/g' build/index.html"
Now, you can simply run:
yarn build # or, npm run build
- A way to know the version of the build of an React App
- What is the best way to build multi-language app with react and redux?
- What is the quickest way to convert a React app to React Native?
- is there a way to build a react app in a single html file?
- What's the easiest way to use Create React App with Relay?
- Is there a way to tell when your react app page is done loading the page / assets?
- The React App works during `npm start` but returns 404 after build
- What is the best way to secure Firebase API keys in a react app so it is not accessible publicly?
- The app build fails when using React Native CLI
- How do I resolve the React app error for npm run build "Failed to compile. Failed to minify the bundle."?
- Build version of react app giving wrong links to CSS and JS files
- Get " a different version of webpack was detected higher up in the tree" error in CRA react app
- How to add build react app (js,css) in to the laravel back end server
- How to determine the order of css in my create react app build with webpack and customize-cra?
- Trying to deploy my REACT Webpack app to heroku. Everything works locally and the heroku build works. But I'm getting a 404 nginx
- What is the way to set X-Frame options in react app
- How create a react app with a specific version using the npx command?
- what is the best way to deploy react app in lan only
- What's the proper way to work with 'react-leaflet' library in a react app made with 'create-react-app'?
- how to install the new version of react app 5.0.0
- How could I hide api key in my React app and host the working version in Github
- Build a CRUD App with React Hooks and the Context API
- Is there a way to set the default font-family for the entire react app without styled-component?
- When I try to use Parcel to build a production version of a React app that works fine in development mode, I get "Cannot find module 'sass'"
- The correct way to store complex form data in React app
- Which is the best way to store a list of data in localStorage and display them when searched using a React app
- NodeJS: What's the best way to share session between server-rendered views and React app
- Append react app directly to body in the right way
- What is the best way to connect React js app with node js server?
- What is the best approach to build a react app with a large amount of component pages?
More Query from same tag
- quilljs replace <strong> with <b>
- how to test a react hook that can have a ref of an html element passed to it
- reactjs checkbox boolean value
- How to move a label on a dropdown form from the top to the side
- Supplied parameters do not match any signature of call target (react-mock-store)
- Use getInitialProps in Layout component in nextjs
- How do you pass custom properties to TypeScript + StyledCompoments?
- How to get static routing after a dynamic routing in Next.js
- How to show/hide an element depending on its previous element in React (TypeScript)
- How get items in object which contains in nested array given value
- Unable to filter out redux state based on values from another local state
- Label doesn't float when dynamically setting Textfield value in Material Design Light and React
- State attribute doesn't get updated when route param changes in React
- Override CSS in React
- How to use React.FC<props> type when the children can either be a React node or a function
- How to make toolbar in material-ui transparent?
- Isomorphic React + Flux + REST API
- Same data in props and state
- using State to get the input value while text is changing. if then, while text is chaing, all will rerender again. does this make the app very slow?
- Webpack - Uncaught TypeError: (0 , _reactDom2.default) is not a function
- React Hook Form set checkbox to checked state
- TypeError: venuesDates.map is not a function React
- Overlay transparent circle on webcam preview in a browser
- Update Many using Mongoose with condition
- sending data through a datalist in react
- TypeError: Cannot set properties of undefined (setting 'styles') + Using withLess/withSass/withCSS in next.config.js NextJS
- React Input don't change when I set a initial value
- Trying to debounce search function calls results in no event passed to a function
- Next.js Unable to serve dynamic images on the runtine
- Why can't I access default props in react constructor, but I can in render?