asyncLiz / minify-html-literals

Minify HTML template literal strings
MIT License
68 stars 13 forks source link

clean-css strips off svg styles like r: 2px #10

Closed s4san closed 4 years ago

s4san commented 4 years ago

I have a code block in lit-html like so,

css`
circle {
  r: 2px;
}
`

But when minifying the file using the plugin, it strips off the circle style completely deeming it to be invalid css due to clean-css plugin

For now, I have solved this issue by following the advice here but this results in the CSS not being minified. I know that the issue is not with this plugin per se, but just wondering if you have any thoughts on how to solve this.

Thanks!

asyncLiz commented 4 years ago

I'm not sure the best way to go around clean-css ignoring invalid properties, but you can pass options to clean-css in this plugin.

minifyHTMLLiterals(template, {
  minifyOptions: {
    minifyCSS: {
      level: {
        2: {
          skipProperties: ['r']
        }
      }
    }
  }
});

My advice would be to find a combination of properties and/or comments that work best for you.