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

exclude files inside the bundle #114

Closed louistb closed 3 years ago

louistb commented 3 years ago

Would it be possible to exclude or include files within the bundle ? Maybe its possible and i dont understand the plugin fully.

Im packing a electron app and i dont want the node_modules obfuscated but i want the app code to be.

Right now it seems like its only possible to include/exclude bundles.

Thanks :)

sanex3339 commented 3 years ago

Hi. Use loader instead of plugin https://github.com/javascript-obfuscator/webpack-obfuscator#loader-usage

louistb commented 3 years ago

Ok got it to work, thanks for the heads up :)

lostb1t commented 3 years ago

@sanex3339 I want todo the same for nextjs but it keeps obfuscation everything and does not seem to listen to the exclude option

  webpack: (config, options) => {
    if (!options.dev && !options.isServer) {
      config.module.rules.push({
        test: /\\.+(ts|tsx)$/,
        exclude: /node_modules/,
        enforce: 'post',
        use: {
          loader: WebpackObfuscator.loader,
          options: {
            compact: true,
            identifierNamesGenerator: 'mangled',
            selfDefending: true,
            stringArray: true,
            rotateStringArray: true,
            shuffleStringArray: true,
            stringArrayEncoding: [],
            stringArrayThreshold: 0.8,
            splitStrings: true,
            splitStringsChunkLength: 6,
            transformObjectKeys: true,
          }
        }
      })
    }

Do you have any pointers?

jsjoeio commented 1 year ago

@sarendsen did you ever figure this out?