Created
July 10, 2020 07:03
-
-
Save yudapc/0f0fae7971c24d52ce4d100896a243e3 to your computer and use it in GitHub Desktop.
REACT CRA Custom BUILD with adding version ?v=
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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