Home > Enterprise >  How to hide the my source code in react.js?
How to hide the my source code in react.js?

Time:01-07

I tried the following formulas to hide the codes of my project in Google Chrome and my codes are hidden, but when I close my project and open it again, the process returns to the beginning and my codes are not hidden. How Can I Solve This?

scripts: {
      "build": "GENERATE_SOURCEMAP=false react-scripts build"
    }

and

env file:

GENERATE_SOURCEMAP=false 

CodePudding user response:

There is no way to hide your front-ends source code. JavaScript is something called interpreted language, which essentially means, that it compiles at runtime, so you have to give your browser source code to for your website to work, the only thing you can do is to build it in the way, that it's extremely hard to read, but never completely hide.

CodePudding user response:

Completely hiding client-side JS code is practically not possible at present. However, you can try these things to make stealing/understanding your code a bit more difficult.

  • use cross-env to inject environment variables
  • obfuscate your code using javascript obfuscation tools
  • disable right click .. etc.

Good luck!

  • Related