fix(schema): correctly set default cssnano config (#23980)

This commit is contained in:
Daniel Roe 2023-10-30 17:57:11 +09:00 committed by GitHub
parent 410cecd93e
commit 802cf7a1e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,7 +6,7 @@ export default defineUntypedSchema({
* Options for configuring PostCSS plugins.
*
* https://postcss.org/
* @type {Record<string, any>}
* @type {Record<string, any> & { 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 {}
}
}
}
}