S
S
Stepan2021-08-10 14:20:00
Code Obfuscation
Stepan, 2021-08-10 14:20:00

How to obfuscate a React app?

For example, I created a simple React application:
npx create-react-app my-app
Then I need to obfuscate the js code. First I found a great tool - Jscrambler, but it's paid. Then I googled about webpack obfuscation and found webpack-obfuscator . According to their documentation, I added the following lines to the webpack.config.js file
:

var WebpackObfuscator = require('webpack-obfuscator');

And added this to the module/rules section :
{
    test: /\.js$/,
    exclude: [],
    enforce: 'post',
    use: {
        loader: WebpackObfuscator.loader,
        options: {
            rotateStringArray: true
        }
    }
},

After I wrote npm run build, and the build was successful, but when I deployed it locally via serve -s build , then instead of the react image, there is an empty page, and the js code error in the console. Probably because of the code obfuscation curve, but what did I do wrong? Maybe there are other tools to obfuscate the React application?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question