elmeet / vite-plugin-javascript-obfuscator

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

Still doesn't work with Nuxt 3 #16

Closed HMaker closed 1 year ago

HMaker commented 1 year ago

The issue https://github.com/elmeet/vite-plugin-javascript-obfuscator/issues/3 was closed as fixed, but it "worked" because the example project didn't include any file to be obfuscated.

I forked the example project to fix the plugin settings, the same error happens Check it at https://stackblitz.com/edit/github-ftj7nb-dedmuj?file=nuxt.config.ts

Run nuxt generate in the terminal:

ERROR  Identifier 'useRuntimeConfig' has already been declared (Note that you need plugins to import files that are not JavaScript)
file: virtual:nuxt:/home/projects/github-ftj7nb-dedmuj/.nuxt/paths.mjs:1:1205
1: import { joinURL } from '/home/projects/github-ftj7nb-dedmuj/node_modules/ufo/dist/index.mjs'
                                                                                                ^
2: import { useRuntimeConfig } from '#internal/nitro'
3: const appConfig = useRuntimeConfig().app

ERROR  Identifier 'useRuntimeConfig' has already been declared (Note that you need plugins to import files that are not JavaScript)

  at error (node_modules/rollup/dist/es/shared/node-entry.js:2150:30)
  at Module.error (node_modules/rollup/dist/es/shared/node-entry.js:13463:16)
  at Module.tryParse (node_modules/rollup/dist/es/shared/node-entry.js:14170:25)
  at Module.setSource (node_modules/rollup/dist/es/shared/node-entry.js:13772:39)
  at ModuleLoader.addModuleSource (node_modules/rollup/dist/es/shared/node-entry.js:23737:20)

The plugin version is "vite-plugin-javascript-obfuscator": "^3.1.0"

chz8494 commented 1 year ago

+1, same error

elmeet commented 1 year ago

Change exclude settings:

exclude: [/node_modules/, /paths\.mjs/, /components\.plugin\.mjs/]
chz8494 commented 1 year ago

tried your suggestion, but still not work, maybe I configured it wrong?

vite: {
    plugins: [
      obfuscatorPlugin({
        exclude: [/node_modules/, /.nuxt\.mjs/, /components\.plugin\.mjs/],
        debugger: true,
        options: {
          compact: true,
          debugProtection: true,
        },
      }),
    ],
  },

can you share the full defineNuxtConfig?

elmeet commented 1 year ago

Modify your configuration. @chz8494

- exclude: [/node_modules/, /.nuxt\.mjs/, /components\.plugin\.mjs/]
+ exclude: [/node_modules/, /paths\.mjs/, /components\.plugin\.mjs/]