From 0ce505a12f49036a5066ebfe2884079decf146c9 Mon Sep 17 00:00:00 2001 From: alex8088 <244096523@qq.com> Date: Sun, 3 Mar 2024 16:45:50 +0800 Subject: [PATCH] perf(bytecodePlugin): warn that strings cannot be protected when minification is enabled (#417) --- src/plugins/bytecode.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/bytecode.ts b/src/plugins/bytecode.ts index d740eb5..70a111d 100644 --- a/src/plugins/bytecode.ts +++ b/src/plugins/bytecode.ts @@ -198,9 +198,12 @@ export function bytecodePlugin(options: BytecodeOptions = {}): Plugin | null { if (useInRenderer) { config.logger.warn(colors.yellow('bytecodePlugin does not support renderer.')) } + if (resolvedConfig.build.minify && protectedStrings.length > 0) { + config.logger.warn(colors.yellow('Strings cannot be protected when minification is enabled.')) + } }, transform(code, id): void | { code: string; map: SourceMapInput } { - if (protectedStrings.length === 0 || !filter(id)) return + if (config.build.minify || protectedStrings.length === 0 || !filter(id)) return let match: RegExpExecArray | null let s: MagicString | undefined