Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Clearly show what cssnext includes (autoprefixer, cssnano...) #180

Closed
MoOx opened this issue Jul 7, 2015 · 20 comments · Fixed by #238
Closed

Clearly show what cssnext includes (autoprefixer, cssnano...) #180

MoOx opened this issue Jul 7, 2015 · 20 comments · Fixed by #238

Comments

@MoOx
Copy link
Owner

MoOx commented Jul 7, 2015

I am tired of notifying people about duplicate use + missuse of cssnext as a plugin. Ref https://github.com/eggsdesign/egg-incubator/issues/1

And #175 will not help, especially if people add autoprefixer after.

We should add something in the doc + automate some warnings. Ref postcss/postcss#325 poke @ai @ben-eb

@MoOx MoOx changed the title Make what cssnext includes (autoprefixer, cssnano...) Clearly show what cssnext includes (autoprefixer, cssnano...) Jul 7, 2015
@ai
Copy link

ai commented Jul 7, 2015

This is question about perfomance or we have some big issue? I think to wait for other plugin packs to understand how people use packs. But I can force this task if we have bigger problem.

@MoOx
Copy link
Owner Author

MoOx commented Jul 7, 2015

It's not a perf issue, more a usage one. It's useless to add some plugins twice.
It's indeed an issue with plugins pack. For now there is not too many, but I think it's enough to decide that we should do something to prevent useless multiple passes...
I will think about that.
Maybe I will add a plugin in cssnext that will check the plugins list during the process() (so I can see all plugins used) in order to add some warnings to the end user.
Yeah, I will do that. I will probably make a postcss plugin to detect and warn about multiple plugins. With an option to pass a whitelist for plugin that might be used more than once (rare use case). Maybe something like postcss-detect-duplicate-plugins.

@ai
Copy link

ai commented Jul 7, 2015

Yeap, plugin.postcssPlugin has added special for this cases.

@ben-eb
Copy link
Contributor

ben-eb commented Jul 7, 2015

@MoOx I've pretty much written it already, it is a core module inside cssnano. I could expand some of the logic, use the warnings API and extract it into a separate module if you like.

@MoOx
Copy link
Owner Author

MoOx commented Jul 7, 2015

Good idea. Please take in mind that I would like to be able to customize the message a little bit so I can produce something like

It seems you (or plugins that you are using) are including X more than once. This is not necessary.

@MoOx
Copy link
Owner Author

MoOx commented Jul 7, 2015

In your case I understand the idea to do that silently for some, but it does make sense to warn for most use cases.

@ben-eb
Copy link
Contributor

ben-eb commented Jul 7, 2015

I can make silent an off by default option. We could do some customisable string substitution, like You are using %s more than once, which is unnecessary.

@MoOx
Copy link
Owner Author

MoOx commented Jul 7, 2015

Yeah. Or more something like a template string (it's es6 below with template string + fat arrow function + destructuring for parameter)

postcss(require("postcss-detect-duplicate-plugins")({
  warningTemplate: ({pluginName}) => `You are using ${pluginName} more than once, which is unnecessary`
})

ES 5 version

postcss(require("postcss-detect-duplicate-plugins")({
  warningTemplate: function(params) {
    return "You are using " + params.pluginName + " more than once, which is unnecessary"
  }
})

@ben-eb
Copy link
Contributor

ben-eb commented Jul 7, 2015

What about this:

  • opts.silent (bool), don't show any warnings
  • opts.format (function), format function for each plugin message
  • opts.exclude (array), plugins that should not be deduplicated

And I like the name postcss-filter-plugins. 👍

@MoOx
Copy link
Owner Author

MoOx commented Jul 7, 2015

lgtm except format name which seems unclear. I think we should go for something verbose like (message|warning)|(Formatter|Template).

@ben-eb
Copy link
Contributor

ben-eb commented Jul 7, 2015

Would opts.template suffice?

@MoOx
Copy link
Owner Author

MoOx commented Jul 7, 2015

Why not. I like long name. I should code in Java.

@ben-eb
Copy link
Contributor

ben-eb commented Jul 19, 2015

@MoOx When warning the user, should we disable the affected plugin too?

@MoOx
Copy link
Owner Author

MoOx commented Jul 19, 2015

Why not, but I would prefer that user disable duplicate usage :)

@ben-eb
Copy link
Contributor

ben-eb commented Jul 19, 2015

Whichever you prefer, it's your use case. 😄

@ben-eb
Copy link
Contributor

ben-eb commented Jul 20, 2015

@MoOx MoOx mentioned this issue Dec 29, 2015
5 tasks
@MoOx MoOx closed this as completed in #238 Jan 4, 2016
@MoOx
Copy link
Owner Author

MoOx commented Jan 4, 2016

Not relevant since postcss-cssnext now do not handle things that it should not (like import, cssnano etc).

@qm3ster
Copy link

qm3ster commented May 16, 2016

So, to be clear:

  1. postcss is the framework for plugins that work on stylesheet AST
  2. cssnano is a distribution of postcss + some plugins already set up in an opinionated way, including notably autoprefixer. It also allows the passing of further plugins, and the passing of objects to the plugins within.
  3. cssnext is distribution of postcss + some plugins already set up in an opinionated way, including notably autoprefixer, not as part of cssnano, and contains all of the plugins that cssnano does, enabled with the compress option?
    Am I getting this right?
    Also, most options mentioned in the migration post are not on the usage page at the time of writing, including the #compress linked from this thread.

@MoOx
Copy link
Owner Author

MoOx commented May 16, 2016

postcss-cssnext is now just a collection of plugin and (except autoprefixer) there is no common plugin used with cssnano.
There is no default "opinionated" config. Autoprefixer is used in "normal" mode in cssnext and in "remove" mode in cssnano.

Like you said, old options that are not on the "usage" page have been removed. That's why there is a migration guide.

@ben-eb
Copy link
Contributor

ben-eb commented May 16, 2016

(except autoprefixer) there is no common plugin used with cssnano.

& postcss-calc. 😄

http://cssnano.co/optimisations/#calc

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants