Closed jceb closed 3 months ago
Hi, since v2.2.0
the option types have been changed to allow for multiple parsers / compressors.
The new option layout is now:
/**
* @module Option
*
*/
export default interface Type extends Option {
/**
* csso, lightningcss option properties
*
*/
CSS?:
| boolean
| {
csso?: csso;
lightningcss?: lightningcss;
};
/**
* html-minifier-terser option properties
*
*/
HTML?:
| boolean
| {
"html-minifier-terser"?: html_minifier_terser;
};
/**
* sharp option properties
*
*/
Image?:
| boolean
| {
"sharp"?: sharp;
};
/**
* terser option properties
*
*/
JavaScript?:
| boolean
| {
"terser"?: terser;
};
/**
* svgo option properties
*
*/
SVG?:
| boolean
| {
"svgo"?: svgo;
};
/**
* Map to different file paths
*
*/
Map?: boolean | _Map;
/**
* Parsers for different file types
*
*/
Parser?: Parser;
}
since v2.2.2
as per: https://github.com/astro-community/AstroCompress/blob/main/Source/Interface/Option.ts
To fix your issue try:
compress({
HTML: {
"html-minifier-terser": {
removeAttributeQuotes: false,
},
},
}),
I would recommend installing a modern editor with autocomplete for TypeScript types such as the VSCode editor, so you can see the suggestions and errors before they happen.
Also installing @astrojs/check
and turning on astro check
before your build process so that errors are shown in the console if you're using a CI.
Apologies for not announcing breaking changes.
Version v2.2.4
will allow for backwards compatibility and proper in-flow of options, meaning you can still pass:
compress({
HTML: {
removeAttributeQuotes: false
}
});
and have it flow properly into the html-minifier-terser
minifier.
@NikolaRHristov where can I find v2.2.4? The latest
tag on npm points to v2.2.3: https://www.npmjs.com/package/astro-compress/v/latest
With v2.2.3 the typings want me to define the HTML properties like this:
compress({
HTML: {
'html-minifier-terser': {
removeAttributeQuotes: true,
}
}
})
Version v2.2.4
is not released yet. Expect it later today.
Since version 2.2.0 I can't pass
removeAttributeQuotes: false
to the HTML minifier anymore like this:The issue that triggered my investigation was broken open graph data - service like Twitter wouldn't display my images anymore. Missing attribute quotes were the reason for the issue. I'd therefore also recommend to change the default of astro-compress to not remove attribute quotes anymore.