browserslist/browserslist-useragent-regexp

Generate from string

evilPaprika opened this issue ยท 4 comments

Is it possible to generate regex passing browserlist as a string(or object)? Using browserlistrc file not always convenient or suitable. ๐Ÿ˜ž

@evilPaprika Hi!

Yes, you can.

https://github.com/browserslist/browserslist-useragent-regexp#cli

for example:

yarn exec -- browserslist-useragent-regexp "defaults, unreleased versions"

@dangreen
Well, I meant in javascript, not as cli utility.
I apologize for not being clear. ๐Ÿฑ

I actually want to avoid using supportedBrowsers.js file and .browserlistrc altogether.

@evilPaprika

https://github.com/browserslist/browserslist-useragent-regexp#options

getUserAgentRegExp(options) method accepts browsers option

getUserAgentRegExp({
  browsers: "defaults, unreleased versions",
  allowHigherVersions: true,
  allowZeroSubversions: true
})

omg thank you so much! ๐Ÿ™
exactly what I need!