Create-react-app: Static files are exponsing my src

Created on 29 Mar 2018  路  5Comments  路  Source: facebook/create-react-app

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

Most helpful comment

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.

All 5 comments

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

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.

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

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 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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xgqfrms-GitHub picture xgqfrms-GitHub  路  3Comments

Aranir picture Aranir  路  3Comments

fson picture fson  路  3Comments

AlexeyRyashencev picture AlexeyRyashencev  路  3Comments

onelson picture onelson  路  3Comments