tuist / SwiftyTailwind

💇 A Swift Package to pull and run Tailwind from a Swift process
https://swiftytailwind.tuist.io
MIT License
58 stars 5 forks source link

How to define TailwindCSS plugins? #29

Open alexandrehsaad opened 6 months ago

alexandrehsaad commented 6 months ago

In my current TailwindCSS project using JS I define plugins in a tailwind.config.js file such as:

plugins: [
    require("@tailwindcss/aspect-ratio"),
    require("@tailwindcss/typography")
]

This file is also where I extended the theme.

With Vapor and SwiftyTailwind, how can I achieve the same thing?

kicsipixel commented 5 months ago

According to the documentation, it worked for me in the past... You can create a tailwind.config.js configuration file by running the initialize function on the SwiftyTailwind instance:

try await tailwind.initialize()
pepicrft commented 5 months ago

When running the tool, you can pass the working directory from where it runs. I believe when Tailwind tries to resolve the plugins, it'll resolve the plugins through the Node module system so as long as those plugins are resolvable from that directory, it should work. For example:

node_modules/
  @tailwindcss/
    aspect-ratio
tailwind.config.js

With the above directory structure, Tailwind should be able to resolve the plugins.