Skip to content

Instantly share code, notes, and snippets.

@yudapc
Created July 10, 2020 07:03
Show Gist options
  • Save yudapc/0f0fae7971c24d52ce4d100896a243e3 to your computer and use it in GitHub Desktop.
Save yudapc/0f0fae7971c24d52ce4d100896a243e3 to your computer and use it in GitHub Desktop.
REACT CRA Custom BUILD with adding version ?v=
VERSION By Unix Timestamps
{
"scripts": {
"postbuild": "VERSION=`date +%s` && sed -i -- 's/js\"/js?v='${VERSION}'\"/g' build/index.html && sed -i -- 's/css\"/css?v='${VERSION}'\"/g' build/index.html && npx rimraf build/**/*.map",
"build": "GENERATE_SOURCEMAP=false react-scripts-ts build && npm run postbuild && gzipper --verbose ./build"
}
}
VERSION by latest commit hash
{
"scripts": {
"postbuild": "VERSION=`git rev-parse HEAD` && sed -i -- 's/js\"/js?v='${VERSION}'\"/g' build/index.html && sed -i -- 's/css\"/css?v='${VERSION}'\"/g' build/index.html && npx rimraf build/**/*.map",
"build": "GENERATE_SOURCEMAP=false react-scripts-ts build && npm run postbuild && gzipper --verbose ./build"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment