postcss / postcss-cli

CLI for postcss
Other
840 stars 93 forks source link

Clarify --config flag for version 6 #233

Closed bep closed 6 years ago

bep commented 6 years ago

--config flag stopped working in version 6

Works fine in 5.

https://github.com/gohugoio/hugo/issues/5001

bep commented 6 years ago

package: removes --config parsing

OK, I see it briefly mentioned in the release notes. That sounds a little brief without mentioning what replaced it? Also, --config is listed in the help output.

RyanZim commented 6 years ago

@bep In the linked issue, you're using the flag incorrectly, --config is used to specify a directory to look for the postcss.config.js file in. You cannot change the filename itself.

bep commented 6 years ago

@RyanZim note that the example in the issue worked fine in 5, but not in 6. Are you telling me that the same flag now is used for something else? I don't understand the reasoning behind this (why take away this flexibility?), but it would be less subtle for end users if you introduced another flag and deprecated the old or something.

/cc @budparr you have tested this, too, right?

RyanZim commented 6 years ago

@bep The old behavior was never intended or documented. The fact that it worked was a bug. We've finally fixed the bug. I realize a fair amount of people were relying on the buggy behavior, that's why it's in a major release.

If you feel we should modify the release notes to state this more explicitly, I'd be happy to do that.

bep commented 6 years ago

If you feel we should modify the release notes to state this more explicitly

It's not in the release notes.

Why was this "never intended", and why is the new behavior considered "better"? Now, if you want multiple setups, you're forced to create multiple directories, which sounds like a much worse situation than the old "buggy" implementation.

RyanZim commented 6 years ago

TBH, I'm personally not a huge fan of the way --config works, but this system of requiring the file to be named postcss.config.js is an PostCSS ecosystem standard used by postcss-loader and others, and I'm trying to keep the CLI compliant with this standard.

If you need multiple setups, the preferred method of handling this is to export a function that returns different values based on ctx.env, then select the config you want on the CLI with --env.

bep commented 6 years ago

OK, thanks for the explanation. I'll keep this issue open if you want to use it to track a change in the release notes. I would also consider making this help text more specific:

--config  Set a custom path to look for a config file
RyanZim commented 6 years ago

Good point on the help message; I'm not crazy good with words; got any suggestions for a more precise, yet concise message?

bep commented 6 years ago

--config Set a custom path to look for a config file

I think it's "path" that gets ambigous very fast.

--config Set a custom directory to look for a config file

Is probably better.

zivbk1 commented 6 years ago

If I understand this correctly, the filename is fixed and all we would need to pass to the config parameter is the directory the file is in. With the default location being in the site root directory.

mistic100 commented 6 years ago

It's a shame we cannot override file name, I like my config files to start with a dot because they are not relevant to the code itself, and this way they are all grouped in the files list. Also it is not coherent with every other tools out there (rollup, webpack, uglify) whose "--config" parameter points to a file.