javascript-obfuscator / webpack-obfuscator

javascript-obfuscator plugin for Webpack
https://github.com/javascript-obfuscator/javascript-obfuscator
BSD 2-Clause "Simplified" License
856 stars 84 forks source link

The expression "Includes" in does not work in excludes. #96

Closed libid0nes closed 3 years ago

libid0nes commented 3 years ago

Hi, I want only one file (specialActivate.js) to be obfuscated in the project, but instead the whole project will be obfuscated. What am I doing wrong?

new WebpackObfuscator ({
  rotateStringArray: true
}, ['!/src/js/specialActivate.js'])
  "devDependencies": {
    "javascript-obfuscator": "^2.8.0",
    ...
    "webpack-obfuscator": "^2.6.0",
  },
wxfred commented 3 years ago

multimatch says

new WebpackObfuscator ({
  rotateStringArray: true
}, ['*', '!/src/js/specialActivate.js'])

But, it is not work.

bewhatyouare commented 3 years ago

Hi,Have you solved this problem?

libid0nes commented 3 years ago

Hi,Have you solved this problem?

Yes:

  configureWebpack: {
    module: {
      rules: [
        {
          test: /specialActivate.js/,
          enforce: 'post',
          use: {
            loader: WebpackObfuscator.loader,
            options: {
              controlFlowFlattening: true,
              controlFlowFlatteningThreshold: 1,
              deadCodeInjection: true,
              deadCodeInjectionThreshold: 1,
              identifierNamesGenerator: 'hexadecimal',
              numbersToExpressions: true,
              rotateStringArray: true,
              selfDefending: true,
              shuffleStringArray: true,
              simplify: true,
              splitStrings: true,
              splitStringsChunkLength: 5,
              stringArray: true,
              stringArrayEncoding: ['rc4'],
              stringArrayWrappersCount: 5,
              stringArrayWrappersChainedCalls: true,
              stringArrayWrappersType: 'function',
              stringArrayThreshold: 1,
              transformObjectKeys: true,
            }
          }
        },
      ]
    },