django-commons / django-tailwind-cli

Django and Tailwind integration based on the prebuilt Tailwind CSS CLI.
https://django-tailwind-cli.rtfd.io/
MIT License
102 stars 11 forks source link

Request: "remove_cli" command #132

Open danjac opened 2 months ago

danjac commented 2 months ago

Hi, thanks first of all for a great utility!

I was wondering if it would be possible to have a Django command equivalent to download_cli, which would remove the CLI using the same path resolution i.e.

./manage.py tailwind remove_cli

This would be useful for example when building a Docker image, where you might build the Tailwind CSS and then remove the CLI, as you no longer need it in production and you want to keep the image as small as possible.

oliverandrich commented 2 months ago

@danjac This sounds like a reasonable addition. But I would suggest solving this using a multi-stage build. I wrote my approach in my latest blog post.

https://andrich.me/2024/09/my-ideal-uv-based-dockerfile/

Look at stage 3 and 4. In stage for, I use the tailwind command to compile my CSS. In stage 4, I assemble the production container. The trick is, that between stage 3 and 4 only the relevant files that you need in production are copied.

But I will consider your request. Nevertheless, you are welcome to provide a pull request.

danjac commented 2 months ago

Sure - multistage build worked for my use case as well.

It might still be useful to have a remove_cli command for some edge cases I guess but certainly not a priority.

Thanks again!