How to build and deploy React app without exposing raw source files
I added the line : "build": "GENERATE_SOURCEMAP=false react-scripts build", to my package.json file but when I build and deploy clearing cache, DigitalOcean still serves the entire project folder. How would you deploy a react app minified without exposing your raw source files?
@Froedrick ah I thought it was a react app inside of laravel.
Either move your index file to a subdirectory and point your web server to it. Or you can set your webserver to deny access to those folders. What web server are you using?
@Sinnbeck from what I gather, DigitalOcean uses Nginx. Their questions section has many Nginx questions, a popular questions link regarding Nginx and absolutely no mention of Apache
@Froedrick but as stated by both @martinbean and me, the recommended practice is moving your public code to a public folder, inside the project, and just change the root inside that nginx config file:)
root /current/path/public; //so just add public here and restart nginx
@froedrick You should only be serving a public folder and not your source folder. If you publish your source folder to a publicly-accessible location then yes, it will be publicly accessible.
@martinbean My source folder is separated from the public folder. This is a standard ReactJS folder structure. I have the project uploaded to Github. Then I use DigitalOcean's instructions to link my Github master branch to my app account and DigitalOcean builds and deploys with one click. I figured this would not be a problem.