elmeet / vite-plugin-javascript-obfuscator

Vite plugin for javascript-obfuscator
MIT License
116 stars 12 forks source link

Vite environment variables undefined #23

Open timpeer opened 3 months ago

timpeer commented 3 months ago

So when on obfuscatorPlugin is defined in plugins i'm not able to read .env variables When i comment it obfuscatorPlugin out env variables works as they should.

New on obfuscating apps so i don't know if this is the way do env variables, should i do it another way? eg. env.js and and when building overwrite it like i do with .env

export default defineConfig(configEnv => {
  const envVariables = JSON.stringify(loadEnv(configEnv.mode, process.cwd()))

  // prints all variables to console
  console.log('defineConfig envVariables', envVariables)

  return {
    define: {
      __APP_ENV__: envVariables, // import.meta.env === undefined
    },
    plugins: [
      obfuscatorPlugin({....
vitaliitrush commented 2 months ago

the same issue.

any updates?

John-Cris-Belga commented 2 months ago

my react vite app is not working when I have import.meta.env.VITE_XXXXX. and when I uninstall vite-plugin-javascript-obfuscator, my app also stops working. Now my app only works if I use vite-plugin-javascript-obfuscator in my vite.config.js

z0ffy commented 2 months ago

Try it with https://www.npmjs.com/package/vite-plugin-bundle-obfuscator