[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 <bjornlu.dev@gmail.com>

* [chore] removes `minify` in favor of user config & Vite defaults

Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
This commit is contained in:
Enteleform 2022-09-20 08:32:58 -04:00 committed by GitHub
parent 4d1b1b583b
commit f53d97d56b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
replaces hard-coded `minify` values with `vite.build.minify`

View file

@ -199,7 +199,6 @@ async function clientBuild(
target: 'esnext', target: 'esnext',
...viteConfig.build, ...viteConfig.build,
emptyOutDir: false, emptyOutDir: false,
minify: 'esbuild',
outDir: fileURLToPath(out), outDir: fileURLToPath(out),
rollupOptions: { rollupOptions: {
...viteConfig.build?.rollupOptions, ...viteConfig.build?.rollupOptions,

View file

@ -239,9 +239,10 @@ export function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin[]
if (output.type === 'asset') { if (output.type === 'asset') {
if (output.name?.endsWith('.css') && typeof output.source === 'string') { if (output.name?.endsWith('.css') && typeof output.source === 'string') {
const cssTarget = settings.config.vite.build?.cssTarget; const cssTarget = settings.config.vite.build?.cssTarget;
const minify = settings.config.vite.build?.minify !== false
const { code: minifiedCSS } = await esbuild.transform(output.source, { const { code: minifiedCSS } = await esbuild.transform(output.source, {
loader: 'css', loader: 'css',
minify: true, minify,
...(cssTarget ? { target: cssTarget } : {}), ...(cssTarget ? { target: cssTarget } : {}),
}); });
output.source = minifiedCSS; output.source = minifiedCSS;