Open wenyongda opened 11 months ago
去掉vite.config.ts里面的配置
obfuscator->options->disableConsoleOutput:true
这个配置去掉
package.json:
"javascript-obfuscator": "^4.1.0",
"rollup-plugin-obfuscator": "^1.1.0",
关键代码
window.onload = () => {
import('vue').then(Vue => {
const { createApp } = Vue;
})
}
Describe the bug
If global is set to false, Identifier "createApp" has already been declared.
To Reproduce
1.global is set to false 2.build the project 3.Identifier "createApp" has already been declared
Stack trace
Package versions:
rollup-plugin-obfuscator
: v1.1.0javascript-obfuscator
: v4.1.0Additional context Add any other context about the problem here. import { resolve, dirname } from "node:path"; import { fileURLToPath } from "node:url"; import { defineConfig } from "vite"; import vue from "@vitejs/plugin-vue"; import webExtension from "@samrum/vite-plugin-web-extension"; import manifest from "./src/manifest"; import AutoImport from "unplugin-auto-import/vite"; import Components from "unplugin-vue-components/vite"; import { NaiveUiResolver } from "unplugin-vue-components/resolvers"; import obfuscator from "rollup-plugin-obfuscator";
const __dirname = dirname(fileURLToPath(import.meta.url));
// https://vitejs.dev/config/ export default defineConfig({ build: { minify: "esbuild", // 默认 }, // esbuild: { // drop: ["console", "debugger"], //打包去除 // }, resolve: { alias: { "@": resolve(__dirname, "src"), }, }, server: { port: 9999, }, plugins: [ vue(), webExtension({ manifest: { ...manifest, }, }), AutoImport({ dts: "src/auto-imports.d.ts", imports: [ "vue", { "naive-ui": [ "useDialog", "useMessage", "useNotification", "useLoadingBar", ], }, "@vueuse/core", ], }), Components({ resolvers: [NaiveUiResolver()], }), obfuscator({ global: false, // options配置项实际为 javascript-obfuscator 选项,具体可查看https://github.com/javascript-obfuscator/javascript-obfuscator options: { compact: true, controlFlowFlattening: true, controlFlowFlatteningThreshold: 0.75, numbersToExpressions: true, simplify: true, stringArrayShuffle: true, splitStrings: true, splitStringsChunkLength: 10, rotateUnicodeArray: true, deadCodeInjection: true, deadCodeInjectionThreshold: 0.4, debugProtection: false, debugProtectionInterval: 2000, disableConsoleOutput: true, domainLock: [], identifierNamesGenerator: "hexadecimal", identifiersPrefix: "", inputFileName: "", log: true, renameGlobals: true, reservedNames: [], reservedStrings: [], seed: 0, selfDefending: true, sourceMap: false, sourceMapBaseUrl: "", sourceMapFileName: "", sourceMapMode: "separate", stringArray: true, stringArrayEncoding: ["base64"], stringArrayThreshold: 0.75, target: "browser", transformObjectKeys: true, unicodeEscapeSequence: true, domainLockRedirectUrl: "about:blank", forceTransformStrings: [], identifierNamesCache: null, identifiersDictionary: [], ignoreImports: true, optionsPreset: "default", renameProperties: false, renamePropertiesMode: "safe", sourceMapSourcesMode: "sources-content",
], });