From bd9794d50f6a8c885068050d3ae85746a91df381 Mon Sep 17 00:00:00 2001 From: hackrobot Date: Wed, 2 Apr 2025 06:37:39 -0500 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E4=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/index.js | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/config/index.js b/config/index.js index a64f7b4..7add554 100644 --- a/config/index.js +++ b/config/index.js @@ -38,25 +38,28 @@ const config = { chunkFilename: "static/css/[name].[contenthash:8].css", }, ]); - // js代码混淆 - chain.plugin("obfuscator").use(WebpackObfuscator, [ - { - rotateStringArray: true, - stringArray: true, - stringArrayThreshold: 0.5, // 降低比例,提高速度 - compact: true, - controlFlowFlattening: false, // 关闭,提高速度 - deadCodeInjection: false, // 关闭,提高速度 - debugProtection: false, - disableConsoleOutput: true, - selfDefending: false, // 关闭,提高速度 - simplify: true, // 开启简化,提高性能 + if (process.env.NODE_ENV === "production") { + // js代码混淆 + chain.plugin("obfuscator").use(WebpackObfuscator, [ + { + rotateStringArray: true, + stringArray: true, + stringArrayThreshold: 0.5, // 降低比例,提高速度 + compact: true, + controlFlowFlattening: false, // 关闭,提高速度 + deadCodeInjection: false, // 关闭,提高速度 + debugProtection: false, + disableConsoleOutput: true, + selfDefending: false, // 关闭,提高速度 + simplify: true, // 开启简化,提高性能 // 禁用对 async/await 的转换 - target: "browser", // 或设置为适合目标环境的 ECMAScript 版本 - disableOptimizations: true, // 禁用某些优化来避免处理 async/await - }, - ["**/*.js", "!node_modules/**"], // 避免对 node_modules 进行混淆 - ]); + target: "browser", // 或设置为适合目标环境的 ECMAScript 版本 + disableOptimizations: true, // 禁用某些优化来避免处理 async/await + }, + ["**/*.js", "!node_modules/**"], // 避免对 node_modules 进行混淆 + ]); + } + chain.module .rule("markdown") .test(/\.md$/)