An Interest In:
Web News this Week
- April 19, 2024
- April 18, 2024
- April 17, 2024
- April 16, 2024
- April 15, 2024
- April 14, 2024
- April 13, 2024
Your React Codes Might Not Be Safe!
If you are using create-react-app
for creating react applications and using yarn build
to get build, your react codes might not be safe.
Because, if you run yarn build
command without any spesification, it will generating source maps as well.
And if you put builded files without deleting source maps to your server, anyone can see your entire react project codes.
How bad is it?
If you go this website, https://svgeditoronline.com/editor/ and open developer tools, and select "Sources" tab. Then you will able to see all project codes sadly.
What we have to do?
We have to delete .map
files from builded files which is in build/static/js
folder.
And for the next build you should change your package.json
build command
find this line
..."build": "react-scripts build",...
change with this
..."build": "GENERATE_SOURCEMAP=false react-scripts build",...
Now, your code is safe. This is a small but important think.
I checked a lot of live react project, also checked selling react scripts on codecanyon, and guess what I found? Almost every project left .map files in static/js
folder.
TL;DR
- Delete all your
.map
files frombuild/static/js
folder. - Change your build command on
package.json
from this"build": "react-scripts build",
to this"build": "GENERATE_SOURCEMAP=false react-scripts build",
for your next builds. - Now you are safe, I hope :)
Original Link: https://dev.to/tayfunerbilen/your-react-codes-might-not-be-safe-8lc
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To