egoist / style-inject

Inject style tag to document head.
MIT License
48 stars 23 forks source link

Add "position" option #4

Closed t4t5 closed 6 years ago

t4t5 commented 6 years ago

Sometimes, it is not desirable to always inject the <style> tag at the end of <head>, since you might want to override some of the styles in CSS.

This adds a third parameter for custom options, where you can specify:

{
  position: "top",
}

Works in a similar way as: https://github.com/webpack-contrib/style-loader#insertat

egoist commented 6 years ago

LGTM

btw I will remove the second arg returnValue later since it's not really necessary.

egoist commented 6 years ago

what about insertTop: true instead of position: 'top'? it seems that there is not any other possible value for position.

t4t5 commented 6 years ago

I changed the option name to insertAt for clarity.

I think you might want to keep the option open for future possible values by not just being a boolean. I noticed that the webpack style-loader allows you to insert the style tag before a specific element for example. Might be an interesting feature to adopt in the future perhaps?

egoist commented 6 years ago

Published as v0.2.0.