Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Allow access to html minify config #348

Open
aubergene opened this issue Aug 7, 2018 · 3 comments
Open

Allow access to html minify config #348

aubergene opened this issue Aug 7, 2018 · 3 comments

Comments

@aubergene
Copy link
Contributor

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.

@hdoro
Copy link

hdoro commented Dec 12, 2019

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 :)

@hmaesta
Copy link

hmaesta commented Jan 18, 2021

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.

@dan-peterson
Copy link

dan-peterson commented May 29, 2021

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"

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants