getkey / rollup-plugin-obfuscator

The most powerful rollup plugin for javascript-obfuscator.
Mozilla Public License 2.0
121 stars 9 forks source link

WebWorker isn't being obfuscated #26

Closed johnschatner closed 8 months ago

johnschatner commented 8 months ago

Describe the bug

Regardless of using global or the include option with the following to find any webworkers they aren't being obfuscated: obfuscator({ include: [ "/*.worker.js", "*/.worker.ts", "/*.worker.jsx", "*/.worker.tsx", ... ]

To Reproduce

  1. Bootstrap Vite app
  2. Add obfuscator to vite.config.js
  3. Notice that any webworkers aren't being obfuscated

Stack trace

If applicable, paste the error here.

Package versions:

Additional context Add any other context about the problem here.

johnschatner commented 8 months ago

For anyone encountering the same problem in the future you have to add the plugin to the worker.plugins prop in your Vite config.

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    react(),
    obfuscator({
      options: {
        // See what's allowed: https://github.com/javascript-obfuscator/javascript-obfuscator
      },
    }),
  ],
  worker: {
    plugins: [
      obfuscator({
        options: {
          // See what's allowed: https://github.com/javascript-obfuscator/javascript-obfuscator
        },
      }),
    ],
  },