phoenixframework / tailwind

An installer for tailwind
MIT License
467 stars 61 forks source link

🗃 Build multiple css files #66

Closed yassinrais closed 1 year ago

yassinrais commented 1 year ago

Is it possible to build several css files?

Example

-> app.css
-> demo.css

to

-> priv/static/assets/app.css
-> priv/static/assets/demo.css
yassinrais commented 1 year ago

Okay, so as far i understand, I found a way to do this by having two watchers

1/2. config.exs

config :tailwind,
  version: "3.1.6",
  app: [
    args: ~w(
      --config=tailwind.config.js
      --input=css/app.css
      --output=../priv/static/assets/app.css
    ),
    cd: Path.expand("../assets", __DIR__)
  ],
  form: [
    args: ~w(
      --config=tailwind.config.js
      --input=css/form.css
      --output=../priv/static/assets/form.css
    ),
    cd: Path.expand("../assets", __DIR__)
  ]

2/2. dev.ex


config :newnix, NewnixWeb.Endpoint,
  #....
  watchers: [
    # Start the esbuild watcher by calling Esbuild.install_and_run(:default, args)
    esbuild: {Esbuild, :install_and_run, [:default, ~w(--sourcemap=inline --watch)]},
    tailwind: {Tailwind, :install_and_run, [:app, ~w(--watch)]},
    tailwind_form: {Tailwind, :install_and_run, [:form, ~w(--watch)]}
  ]```
chrismccord commented 1 year ago

Two watchers would be the way to go. Thanks!