Skip to content
This repository was archived by the owner on Aug 17, 2021. It is now read-only.

Adding a script to integrate tailwind-ppx into codebase#83

Merged
dylanirlbeck merged 11 commits intomasterfrom
@dylanirlbeck/add-integration-script
May 15, 2020
Merged

Adding a script to integrate tailwind-ppx into codebase#83
dylanirlbeck merged 11 commits intomasterfrom
@dylanirlbeck/add-integration-script

Conversation

@dylanirlbeck
Copy link
Copy Markdown
Owner

@dylanirlbeck dylanirlbeck commented May 11, 2020

Fixes #81

This script would transform every existing instance (in a .re file) of className="..." into className=[%tw "..."] by calling ./node_modules/@dylanirlbeck/tailwind-ppx/use_ppx.exe.

I should making the path to the script easier to execute, but this might not be necessary.

TODO

  • Corresponding README update with instructions, stress need for a root bsconfig.json (with a note that script could wrongly execute if bsconfig is found earlier than project root)
  • Investigate adding CLI parameters like --files **/glob (just doing all .re files)
  • Reconsider file structure and naming conventions of folders/modules/etc
  • Add a test (or two)

@tatchi
Copy link
Copy Markdown
Collaborator

tatchi commented May 12, 2020

Nice addition! :)

From my understanding, all classnames are being wrapped in [%tw "..."]. That's probably too aggressive, what about other classnames (not from tailwind)? Let's say that one has created a classname .custom_classname and uses it alongside tailwind classnames:

<div className="custom_classname flex flex-col items-center" />

It gets transformed to:

className=[%tw "custom_classname flex flex-col items-center"]>

Which is wrong and will produce an error since the ppx will then detect that custom_classname is not a valid tailwind class.

Since we are already able to extract class names from the tailwindcss file, I think we should only transform these classes. So the example above should become something similar to:

className={"custom_classname " ++ [%tw "flex flex-col items-center"]}>

@github-actions
Copy link
Copy Markdown

I have updated your lock dirs and formatted the code. Please @dylanirlbeck pull the last commit before pushing any more changes.

@dylanirlbeck dylanirlbeck marked this pull request as ready for review May 15, 2020 07:23
@dylanirlbeck dylanirlbeck merged commit e7961a4 into master May 15, 2020
@dylanirlbeck dylanirlbeck deleted the @dylanirlbeck/add-integration-script branch May 15, 2020 21:10
@tatchi tatchi mentioned this pull request Jun 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create script to integrate the PPX on entire codebase

2 participants