bluzky / salad_ui

Phoenix Liveview component library inspired by shadcn UI
https://salad-storybook.fly.dev/welcome
MIT License
245 stars 12 forks source link

Could not read file /app/assets/tailwind.colors.json - tails.ex #7

Closed ashkan117 closed 4 weeks ago

ashkan117 commented 4 weeks ago

Hello,

Love the work on this project! The components like tooltip and the dropdown are exactly what I needed so I'm testing this out in my project. It seems to work locally but if I try and deploy I get this error

== Compilation error in file lib/tails.ex ==
** (File.Error) could not read file "/app/assets/tailwind.colors.json": no such file or directory
     (elixir 1.15.7) lib/file.ex:358: File.read!/1
     lib/tails.ex:3: (module)

Do you have any advice on what I can check?

ashkan117 commented 4 weeks ago

The issue was now the compile step depends on the assets due to the tails library. I updated my dockerfile to move step that copies the assets to before the compile step

# dockerfile
COPY assets assets
RUN mix deps.compile

This does change the error to the following

Cannot find module 'tailwindcss/plugin'
7.756 Require stack:
7.756 - /app/assets/tailwind.config.js
...
7.756   code: 'MODULE_NOT_FOUND',
7.756   requireStack: [ '/app/assets/tailwind.config.js' ]
bluzky commented 4 weeks ago

@ashkan117 salad_ui depends on another package for css animation

cd assets
npm i -D tailwindcss-animate
# or yarn
yarn add -D tailwindcss-animate
ashkan117 commented 4 weeks ago

I think I do that in my deployment setup.

#package.json
{
  "devDependencies": {
    "tailwindcss-animate": "^1.0.7"
  },
}

And in my Dockerfile I do npm install

ashkan117 commented 4 weeks ago

I think the issue was that npm install does not install dev dependencies in my case So the following steps ended up fixing things for me

# Copy assets before running deps.compile
COPY assets assets
RUN mix deps.compile

# Install the animate dependency before assets.deploy
RUN cd assets && npm i -D tailwindcss-animate