From 802cf7a1e91b24ea9b4105658fd75660455aee0c Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Mon, 30 Oct 2023 17:57:11 +0900 Subject: [PATCH] fix(schema): correctly set default cssnano config (#23980) --- packages/schema/src/config/postcss.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/schema/src/config/postcss.ts b/packages/schema/src/config/postcss.ts index 19c44f7acd..a1be5bcec3 100644 --- a/packages/schema/src/config/postcss.ts +++ b/packages/schema/src/config/postcss.ts @@ -6,7 +6,7 @@ export default defineUntypedSchema({ * Options for configuring PostCSS plugins. * * https://postcss.org/ - * @type {Record} + * @type {Record & { autoprefixer?: any; cssnano?: any }} */ plugins: { /** @@ -14,14 +14,19 @@ export default defineUntypedSchema({ */ autoprefixer: {}, + /** + * https://cssnano.co/docs/config-file/#configuration-options + */ cssnano: { - $resolve: async (val, get) => val ?? !(await get('dev') && { - preset: ['default', { - // Keep quotes in font values to prevent from HEX conversion - // https://github.com/nuxt/nuxt/issues/6306 - minifyFontValues: { removeQuotes: false } - }] - }) + $resolve: async (val, get) => { + if (val || val === false) { + return val + } + if (await get('dev')) { + return false + } + return {} + } } } }