passy / autoprefixer-loader

Webpack loader for autoprefixer
MIT License
217 stars 25 forks source link

Comma separated syntax for `browsers` does not work #1

Closed szag closed 9 years ago

szag commented 10 years ago

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().

passy commented 10 years ago

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 10 years ago

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 10 years ago

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

necolas commented 10 years ago

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?

passy commented 10 years ago

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

necolas commented 10 years ago

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

passy commented 10 years ago

@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 https://github.com/passy/autoprefixer-loader/issues/1#issuecomment-54690977 .

matthewwithanm commented 10 years ago

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

deepsweet commented 9 years ago

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