gulp-inline-css icon indicating copy to clipboard operation
gulp-inline-css copied to clipboard

Don't remove link with attribute data-embed

Open tomkrej opened this issue 6 years ago • 8 comments
trafficstars

Hi, I have small wish :) I am newsletter developer a I use gulp-inline-css in my devstack with two cases. First I have external link to style.css () which I need to inline and remove. And second external link for Google Fonts () which I don't want remove.

I tried to add data attribute data-embed, but it still remove element.

Can you help me, please?

tomkrej avatar Sep 11 '19 07:09 tomkrej

I second this request. My links to to Google fonts get stripped out.

howeller avatar Sep 18 '20 18:09 howeller

This option doesn't work?

https://github.com/jonkemp/gulp-inline-css#optionsremovelinktags

jonkemp avatar Sep 25 '20 13:09 jonkemp

Oh I see what you are saying. Seems like data-embed is the solution here but maybe it doesn't work for the link tag.

jonkemp avatar Sep 25 '20 13:09 jonkemp

Maybe having an data-embed-ignore attribute for link tags to be left alone entirely. Thank you for looking into this!

howeller avatar Apr 19 '21 23:04 howeller

Any updates? Same problem with Google fonts

xxxKOTxxx avatar Feb 07 '23 04:02 xxxKOTxxx

Curious if this is being addressed? Also having a problem with Google Fonts being stripped.

Chris-Reedy avatar Jun 07 '23 21:06 Chris-Reedy

Also came here for the same issue, want to ignore certain link tags, like google fonts.

cb911nr avatar Sep 11 '23 16:09 cb911nr

UPDATE

If you use data-embed="" in a Google webfont <link>, it won't be stripped. Here are the steps...

Step 1: make sure rel="stylesheet" isn't in the <link> attribute (will interrupt gulp-inline-css) Step 2: add inline-webfontlink="" as a place holder so we can add the rel="stylesheet" back in later or else the webfont won't render (see 1st image, below) Step 3: add data-embed="" to the <link> after the inline-webfontlink="" declaration (see 1st image, below) Step 4: make sure your gulp-inline-css settings are correct (see 2nd image, below) Step 5: add .pipe(replace(/inline-webfontlink="(.*)"/g, 'rel="stylesheet"')) as the last item in your var inline = function(path) { (see 3rd image, below) Step 6: view source of rendered code to confirm (see 4th image, below)

1. HTML:

image

2. Settings:

image

3. var inline:

image

4. Rendered:

image

Credit in part to @chrisgrouge

Chris-Reedy avatar Sep 18 '23 19:09 Chris-Reedy