sapper icon indicating copy to clipboard operation
sapper copied to clipboard

Allow access to html minify config

Open aubergene opened this issue 7 years ago • 3 comments
trafficstars

Currently the HTML minify config is hard coded. I need to use SSIs in my template, so I'm using a fork. It would be good to be able to change the config with a Sapper project, but I wasn't sure the best way to enable this.

aubergene avatar Aug 07 '18 15:08 aubergene

Same here! Besides @aubergene 's use for comments, which is impossible in Sapper's current state, WhatsApp link sharing only understands og:image if its meta tag is formatted with commas:

<!-- This works, WhatsApp reads into the comments -->
<meta property=og:image content=https://biptt-dev.netlify.com/ogImageSquare.png >
<!-- <meta
  property="og:image"
  content="https://biptt-dev.netlify.com/ogImageSquare.png"
/> -->

<!-- This doesn't work (line below unchanged) -->
<meta property=og:image content=https://biptt-dev.netlify.com/ogImageSquare.png >

<!-- Now it works (has commas) -->
<meta property="og:image" content="https://biptt-dev.netlify.com/ogImageSquare.png" >

See for yourselves with the minified version and the formatted version (grab the URLs and share them on WhatsApp, the image won't show up).

This is very grave and might be hurting tons of websites' conversions as social sharing is a big aspect of driving people to the site.

The quick-fix should be easy: just set removeAttributeQuotes: false in html-minifier's configuration! I will make a PR tomorrow if I have the time 😉

As to a more long-term solution, I'd say we follow Julian's idea of exposing the html-minifier configuration :)

hdoro avatar Dec 12 '19 23:12 hdoro

A really non-recommended workaround for the ones who really needs this...

  1. Edit node_modules/sapper/dist/minify_html.js to your taste
  2. Run yarn export

Again: not recommended. Do by your own risk.

hmaesta avatar Jan 18 '21 21:01 hmaesta

Another option if you're between a rock and a hard place is to monkey patch it on post install:

"postinstall": "mv src/minify_html.js node_modules/sapper/dist/minify_html.js"

dan-peterson avatar May 29 '21 00:05 dan-peterson