create-react-app icon indicating copy to clipboard operation
create-react-app copied to clipboard

Static files are exponsing my src

Open wellmonge opened this issue 8 years ago • 5 comments

Static files are exponsing my src

Hi there, I'm facing a problem on deployment with creat-react-app: my src files are expose, how can I remove them from statics without eject?

My source tree

image

wellmonge avatar Mar 29 '18 13:03 wellmonge

This looks like the development environment, which is expected. This shouldn't happen in production.

Timer avatar Mar 31 '18 02:03 Timer

This happens here too, but if I remove the map files, everything's fine. I know that source maps are helpful for debuggers and browsers, but are they really necessary in production? If the answer is yes, how could we also keep them but avoid having the files exposed?

Using node 9.3.0 and express with nodemon.

PaulRBerg avatar Mar 31 '18 12:03 PaulRBerg

You can add a postbuild script in package.json that moves the files to a different directory or deletes them.

iansu avatar Mar 31 '18 17:03 iansu

If you want to remove sourcemaps you can do it like this. https://github.com/facebook/create-react-app/issues/1341#issuecomment-270108407

Note that this doesn't "protect" your code. Any code shipped to the client can be inspected and reverse engineered, regardless of whether it's minified or not.

gaearon avatar Apr 03 '18 17:04 gaearon

@gaearon I believe the aim here is not to prevent reverse engineering but rather make it harder to do so. Any code can be reverse engineered the question is how easy you want it to be.

hareeqi avatar Jul 03 '18 20:07 hareeqi