pascalduez / postcss-map

PostCSS plugin enabling configuration maps
The Unlicense
121 stars 7 forks source link

Add usage with postcss-plugin-context? #11

Closed ben-eb closed 9 years ago

ben-eb commented 9 years ago

I released this last night: https://github.com/postcss/postcss-plugin-context

One of the main reasons I wrote it was to be able to sandbox plugins such as postcss-map, so that I could say define a brand colour context and use the shorthand there, and say a theme colour context which could load a different file but yet still use the shorthand.

Do you think we can add a space in the README for usage with this module?

I would also like to register my interest in https://github.com/pascalduez/postcss-map/issues/3 - I would prefer if postcss-map were to throw an error if it could not find a key in the map. This would work much better with postcss-plugin-context, and I would be happy to update its README to explain this.

pascalduez commented 9 years ago

Do you think we can add a space in the README for usage with this module?

Sure thing!

Your module makes me think I could implement some sort of per file default map setting. Will think of it a bit more.

Error handling is the next priority task, as of #3 and #7.

Is it better to use the new message API or directly throw ? Or both.

ben-eb commented 9 years ago

I think you want to use the PostCSS error API, such as this: https://github.com/postcss/postcss-plugin-context/blob/master/index.js#L27

postcss-plugin-context will throw if you used a context that is not in its configuration, to guard against typos. I believe map should also throw as the map() function is not standard CSS which can be used outside the plugin.

ben-eb commented 9 years ago

Thanks for fixing! (https://github.com/pascalduez/postcss-map/commit/7e64ba8eca393cd0bf82c1ad271a1b91f6e423bd)