Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supports more attributes #259

Open
alexander-akait opened this issue Mar 17, 2020 · 15 comments
Open

Supports more attributes #259

alexander-akait opened this issue Mar 17, 2020 · 15 comments

Comments

@alexander-akait
Copy link
Member

alexander-akait commented Mar 17, 2020

  • Operating System: any
  • Node Version: any
  • NPM Version: any
  • webpack Version: any
  • html-loader Version: 1

Feature Proposal

Supports more attributes:

  • style - parse url() in CSS
  • script with src and without src like entry

Feature Use Case

0CJS

@benjaminpreiss
Copy link

I would like to nominate the video tag poster attribute for this list of attributes!

I stumbled upon it today when trying to use videojs...
Wouldn't it be possible to allow custom named attributes?
E.g.:

loader: "html-loader",
options: {
    attributes: {
      list: [
        {
          tag: 'video',
          attribute: 'poster',
          type: 'src'
        },
      ],
    },
}

@alexander-akait
Copy link
Member Author

@alexander-akait
Copy link
Member Author

We already support the poster attribute for video tag, check your version of html-loader

@benjaminpreiss
Copy link

Ah sorry for the mistake. :/

@GuillermoCasanova
Copy link

Is there support for data-srcset on source? Just submitted an issue for this. #316

@alexander-akait
Copy link
Member Author

@GuillermoCasanova It is non standard, other developers can have any data in this, you need to use options for this, the only way I can help here allow to define list of attributes in easy way:

{ 
 list: [
  // Means all default attributes
  '...', 
  {  
    tag: 'img',
    attribute: 'data-srcset',
    type: 'srcset',
  }
 ] 
}

@bigskillet
Copy link

bigskillet commented Oct 23, 2020

  • link:rel=icon:href
  • meta:msapplication-TileImage
  • meta:msapplication-config
  • link:rel=mask-icon:href
  • link:rel=apple-touch-icon:href
  • link:rel=apple-touch-icon-precomposed:href
  • link:rel=apple-touch-startup-image:href
  • link:rel=manifest:href
  • link:rel=shortcut icon:href
  • style - parse url() in CSS

Having these attributes as default would be awesome and especially useful since the interpolate option has been removed. In the meantime, is there some way to add these attributes manually?

@alexander-akait
Copy link
Member Author

I think it is easy to implement, feel free to send a PR

@bigskillet
Copy link

Sorry, I'm not that good at javascript, so it wouldn't be that easy for me to include these attributes. I pulled it down and made an attempt, but didn't have much luck. In the meantime, is there some way to manually add these attributes using the list tag filter? I haven't had much luck with that either.

@alexander-akait
Copy link
Member Author

alexander-akait commented Nov 18, 2020

WIP on this, release will be tomorrow after tomorrow

@elliotleelewis
Copy link

@alexander-akait Just curious if you have any timeline on getting this implemented? 😃

@alexander-akait
Copy link
Member Author

@elliotleelewis What is attribute you need?

@elliotleelewis
Copy link

@elliotleelewis What is attribute you need?

@alexander-akait The URL property in style attributes, like so:

<div id="background-image" style="background-image: url('./assets/media/photo.jpg')"></div>

@alexander-akait
Copy link
Member Author

Yep, try to find time on this at the end of month...

@elliotleelewis
Copy link

Yep, try to find time on this at the end of month...

Perfect, thank you!

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

No branches or pull requests

5 participants