From f53d97d56be809a4c4a7f7d7ad79a22b36d8cd28 Mon Sep 17 00:00:00 2001 From: Enteleform Date: Tue, 20 Sep 2022 08:32:58 -0400 Subject: [PATCH] [chore] replaces hard-coded `minify` values with `vite.build.minify` (#4803) * [chore] replaces hard-coded `minify` values with `vite.build.minify` * [style] changes ternary to not-equals Co-authored-by: Bjorn Lu * [chore] removes `minify` in favor of user config & Vite defaults Co-authored-by: Bjorn Lu --- .changeset/tender-nails-sip.md | 5 +++++ packages/astro/src/core/build/static-build.ts | 1 - packages/astro/src/core/build/vite-plugin-css.ts | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/tender-nails-sip.md diff --git a/.changeset/tender-nails-sip.md b/.changeset/tender-nails-sip.md new file mode 100644 index 000000000..0eb74c336 --- /dev/null +++ b/.changeset/tender-nails-sip.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +replaces hard-coded `minify` values with `vite.build.minify` diff --git a/packages/astro/src/core/build/static-build.ts b/packages/astro/src/core/build/static-build.ts index d7b9d5026..810e17974 100644 --- a/packages/astro/src/core/build/static-build.ts +++ b/packages/astro/src/core/build/static-build.ts @@ -199,7 +199,6 @@ async function clientBuild( target: 'esnext', ...viteConfig.build, emptyOutDir: false, - minify: 'esbuild', outDir: fileURLToPath(out), rollupOptions: { ...viteConfig.build?.rollupOptions, diff --git a/packages/astro/src/core/build/vite-plugin-css.ts b/packages/astro/src/core/build/vite-plugin-css.ts index 5dd680c04..04403aed5 100644 --- a/packages/astro/src/core/build/vite-plugin-css.ts +++ b/packages/astro/src/core/build/vite-plugin-css.ts @@ -239,9 +239,10 @@ export function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin[] if (output.type === 'asset') { if (output.name?.endsWith('.css') && typeof output.source === 'string') { const cssTarget = settings.config.vite.build?.cssTarget; + const minify = settings.config.vite.build?.minify !== false const { code: minifiedCSS } = await esbuild.transform(output.source, { loader: 'css', - minify: true, + minify, ...(cssTarget ? { target: cssTarget } : {}), }); output.source = minifiedCSS;