roots / palette-webpack-plugin

Generate a JSON file containing your color palette from existing Sass maps and/or Tailwind.
MIT License
46 stars 7 forks source link

Custom color palettes unsupported #17

Open lgladdy opened 3 years ago

lgladdy commented 3 years ago

Tailwinds supports custom color palettes: https://tailwindcss.com/docs/customizing-colors#custom-colors

At the moment, this plugin has very weird behaviour with this kind of configuration as it's looking for numbered shades as per a default configuration.

I've quickly patched this on a fork so we can continue working with it (https://github.com/lgladdy/palette-webpack-plugin/commit/74fb5c59860bcf963373c05743cf7b8e5bd81085) but I'm not sure of the repercussions of removing isNaN, so didn't want to submit it as a PR without discussion.

If you follow the custom configuration example on tailwind's docs, you'll end up with duplicate key names because of the isNaN check, and the majority of your colours will be excluded. Removing this isNaN check (and enabling shades) forces the correct generation with my patch, but this is probably not the best way of moving forward.

Potentially, the best solution would be to check for NaN keys which still have a value, and auto-enable shades in that case, and remove the isNaN check?

I'm happy to write this code and submit a PR, but would value some input from the core dev(s) on if this seems sensible?

lgladdy commented 3 years ago

I've made another revision on my fork too to deal with "default" being stripped out by tailwind. We'll need to include that too. (https://github.com/lgladdy/palette-webpack-plugin/commit/e6ed99c4ed0be70d063fbcbf03e2c2a6a718126d)

Log1x commented 3 years ago

Feel free to start up a PR for this.