How to run Tailwind based on ETS or state in production mode

Hello, I am creating a template creator for my CMS (MishkaCms), so I let users create a template for each part of their site with dropping and dragging.
It is based on Tailwind CSS and my problem is, how can I run Tailwind based on my state (LiveView) or ETS. I store all the user stuff in a map, and it is not saved in html, so Tailwind CSS even in development mode can not recognize is there a change.

1- how can run Tailwind with ETS or State?


Please see this video:

My other difficulty is I need all of them in production mode, because I let users create their template in runtime and call it from ETS and if they want to install it I have developed another plugin (GitHub - mishka-group/mishka_installer: Mishka Installer is a system plugin manager and run time installer for elixir).

2- So after running Tailwind, How can move new CSS and replace it with current one?

These problems block my project and if I have your help I can provide an opportunity for the CMS and rewrite it.

Thank you for the help in advance



My ETS or State example:

[
  %{
    children: [
      %{
        children: [],
        class: ["font-sans", "md:font-sans"],
        id: "0034f2d7-fa04-44b1-8f22-2d57fec2bbdd",
        index: 0,
        parent: "layout",
        parent_id: "6324852c-2504-45a5-b9d5-19b26122be53",
        type: "section"
      }
    ],
    class: ["shadow-sm"],
    id: "6324852c-2504-45a5-b9d5-19b26122be53",
    index: 0,
    parent: "dragLocation",
    parent_id: "dragLocation",
    type: "layout"
  }
]

The class list is the Tailwind config for each block (example a div)

There are only 2 ways in my mind,

  1. Create a sample HTML to have all the classes and let the tailwindcss scan it, it is good for development and I have no access to it in production I think? Am I right?
  2. Use npx tailwindcss to create a CSS file, but it is a big dependency for my user, it has to install in his/her server.

Unfortunately, I could not find another way, to pass HTML or tailwind class, and it returns CSS lines or a file