passy/autoprefixer-loader

Comma separated syntax for `browsers` does not work

Closed this issue · 9 comments

szag commented

First, thanks for writing this loader! While testing it in my project I found this:

Specifying the browsers in a query string using comma separation as shown in the README (?browsers=last 2 version, Firefox 15) does not work. Only the first value would be passed to autoprefixer.

This is because the loader-utils parseQuery() interprets a comma as a separator between flags (?+flag1,-flag2 -> { flag1: true, flag2: false }). Hence only the first value will be assigned to browsers while all subsequent values will become flags set to true.

Only the JSON ?{browsers:['last 2 version', 'Firefox 15']} and array ?browsers[]=last 2 version,browsers[]=Firefox 15 syntax would work with parseQuery().

Oh, that makes sense. So do you think what you mentioned there is okay and the docs should be updated or does the plugin itself need to be changed?

szag commented

Although it's a bit more verbose the JSON syntax works fine for me. One could introduce another separator like ; but for compatibility to loader-utils and other loaders using it I would stick to the syntax required by parseQuery().

Thus I think updating the docs with working examples would be sufficient.

szag commented

As an unrelated side note it might also be nice to get your loader in the official list oft loaders. Don't know how, maybe posting in the gitter channel

Since the options for AP can be quite verbose (especially when setting lots of browsers), what about adding an options property to the webpack config?

@necolas Do you know of a different plugin that does that?

@necolas Thanks, I'll have a look.
On Sep 6, 2014 12:47 AM, "Nicolas Gallagher" notifications@github.com
wrote:

this one: https://github.com/okonet/rework-loader


Reply to this email directly or view it on GitHub
#1 (comment)
.

It might be nice to error on unexpected flags…right now it just fails silently so you won't know the output's wrong.

+1 for adding an options property to the webpack config instead of query params, chunks building log looks very bloated because of it.