From 9b5c0377cd3474447c84b2901801287f3caf3d82 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Sun, 26 Jan 2025 11:28:39 +0530 Subject: [PATCH] fix(build): `--minify` not working as documented closes #4523 --- src/node/build/bundle.ts | 8 +------- src/node/cli.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/node/build/bundle.ts b/src/node/build/bundle.ts index e4d2556c..662e9593 100644 --- a/src/node/build/bundle.ts +++ b/src/node/build/bundle.ts @@ -88,13 +88,7 @@ export async function bundle( ssr, ssrEmitAssets: config.mpa, // minify with esbuild in MPA mode (for CSS) - minify: ssr - ? config.mpa - ? 'esbuild' - : false - : typeof options.minify === 'boolean' - ? options.minify - : !process.env.DEBUG, + minify: ssr ? !!config.mpa : (options.minify ?? !process.env.DEBUG), outDir: ssr ? config.tempDir : config.outDir, cssCodeSplit: false, rollupOptions: { diff --git a/src/node/cli.ts b/src/node/cli.ts index 5e0be858..cf8ce305 100644 --- a/src/node/cli.ts +++ b/src/node/cli.ts @@ -12,6 +12,14 @@ if (process.env.DEBUG) { const argv: any = minimist(process.argv.slice(2)) +Object.keys(argv).forEach((key) => { + if (argv[key] === 'true') { + argv[key] = true + } else if (argv[key] === 'false') { + argv[key] = false + } +}) + const logVersion = (logger: Logger) => { logger.info(`\n ${c.green(`${c.bold('vitepress')} v${version}`)}\n`, { clear: !logger.hasWarned