PoC for checking for app updates
Try it out by running:
yarn install
then installing serve
globally if not installed yet by running
yarn add serve -g
We need to build the app for production by running
yarn build
and then serve it by running
serve -s build
It should open on localhost:3000
To see the version change and update/show it on the front page we have to
- Change the
version
inpackage.json
- Shut down the server
- Run
yarn build && serve -s build
- Remember not to refresh (so that the old app is running still) the page and let it find the update
What is required for this to work apart from the hook/js implementation are two things:
- A metatag added to index.html
<meta name="app-version" content="%REACT_APP_VERSION%" />
- An env variable
REACT_APP_VERSION=$npm_package_version
The metatag can be added to the HTML in numerous ways, one of them being HTMLWebpackPlugin which could inject it during build time.