Webpack HTML minifier正在从CSS规则中删除CMS {variables}。

huangapple go评论56阅读模式
英文:

Webpack HTML minifier is removing CMS {variables} from CSS rules

问题

我需要帮助使用html-minimizer-webpack-plugin。现在,当我写这样的代码:

<style>
.video__embed {
aspect-ratio: {video_width}/{video_height} !important; 
padding-top: 0 !important;
}
</style>

压缩器会移除{video_width}/{video_height}!important; padding-top: 0 !important;,导致如下结果:

<style>.video__embed{aspect-ratio:{};}</style>

我如何配置这个插件以保持这些值不变,但仍然进行压缩?

英文:

I need help with html-minimizer-webpack-plugin. Right now, when I write this:

<style>
.video__embed {
aspect-ratio: {video_width}/{video_height} !important; 
padding-top: 0 !important;
}
</style>

minifier removes {video_width}/{video_height}!important; padding-top: 0 !important;, resulting in

<style>.video__embed{aspect-ratio:{};}</style>

How can I configure the plugin to keep those values intact, but still minified?

答案1

得分: 1

aspect-ratio: {video_width}/{video_height} !important;

这不是有效的CSS语法。我认为你应该在使用缩小器之前将其转译为有效的CSS。

英文:
aspect-ratio: {video_width}/{video_height} !important;

This is not a valid CSS syntax. I think you should transpile this to valid CSS before use minimizer.

huangapple
  • 本文由 发表于 2023年2月26日 21:44:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/75572403.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定