Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Callbacks as plugins #116

Closed
alexlafroscia opened this issue Jul 28, 2017 · 3 comments
Closed

Callbacks as plugins #116

alexlafroscia opened this issue Jul 28, 2017 · 3 comments

Comments

@alexlafroscia
Copy link
Contributor

I have another request/proposal!

One thing that I've come across (rarely) is the need to configure a PostCSS plugin with information about the current directory of the files being operated on. Specifically, I've run into this with postcss-sprites and the need to locate the sprites themselves. Brococli makes this a bit tough, since you don't actually know where the files are on disk anymore.

We solves this issue by allowing a plugin to be a callback, that was threaded the output directory and the current file being processed. You can check out the code we've used here.

Would you be willing to consider a third type of plugin, a callback, in addition to the two methods supported here? Again, I'll add the feature (and tests) if you're willing to accept a PR that added that feature.

Thanks!

@jeffjewiss
Copy link
Owner

Hey, sorry for the delay on this one.

I was trying to think about your use case a bit. I'm hesitant to add more types of plugins unless it's really necessary. I'm a little worried about the configuration becoming too tedious or error prone.

Regarding the example you gave, is postcss-sprites the only plugin where this has been an issue? Since spritePath: './dist/images/' is a relative path, and { from, to} are passed to the plugin as options, is it possible to configure the plugin with that that info or is the use case more complicated and I'm missing something?

I was hoping that passing the relative path of the file to each plugin would be enough since this package is generally used in the postprocess step and broccoli-postcss-single is used as a main processor.

Let me know what you're thinking and we can likely work something out for this use case.

@alexlafroscia
Copy link
Contributor Author

alexlafroscia commented Aug 21, 2017

I was able to work around my issue -- not by using a relative path, but by just not doing sprites altogether 😝 Data URIs work just as well for me, and we got a different PostCSS plugin working to handle that instead.

@jeffjewiss
Copy link
Owner

Glad to hear you were able to find a work around! Thanks for following up on this issues. Cheers.

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

No branches or pull requests

2 participants