getkey / rollup-plugin-obfuscator

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

Obfuscator breaks code when using import.meta.env #15

Closed doroved closed 1 year ago

doroved commented 1 year ago

Describe the bug

Hi, thanks for the update! I encountered an error that appears when using ENV. How can it be resolved?

import ky from 'ky'

const api = ky.create({
  prefixUrl: import.meta.env.VITE_APP_API,
  headers: {
    Authorization: localStorage.authToken || '',
  },
})
image

Stack trace

Uncaught TypeError: Cannot read properties of undefined (reading 'VITE_APP_API')

Package versions:

getkey commented 1 year ago

This is basically the same problem as #11. I described a solution in this comment https://github.com/getkey/rollup-plugin-obfuscator/issues/11#issuecomment-1426468581 (there might be other solutions, if so let me know).

Reopen if that doesn't fix it for you!

doroved commented 1 year ago

Thank you. It all worked out. I have one more question, I want the obfuscation code to look like this

image

But your plugin obfuscates like this

image

I would like to have the first example of how to do this? I am using the default options. In the first example plugin: vite-plugin-obfuscator

huhai122 commented 1 month ago

谢谢。一切都解决了。 我还有一个问题,我希望混淆代码看起来像这样 图像

但是你的插件会像这样混淆 图像

我想看第一个示例,说明如何执行此操作? 我使用的是默认选项。 第一个示例中的插件:vite-plugin-obfuscator

how do you fix that?