-
Notifications
You must be signed in to change notification settings - Fork 752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rails 8 + Importmaps - missing backdrop #998
Comments
I've created an app with esbuild and backdrop works fine |
@jbwl May I ask you to explain your point of view? |
@alec-c4 you didn't add the css into your project, that's likely why it's not picking up the backdrop |
@bitshaker and https://github.com/alec-c4/flowbite_issue/blob/fd8c7059d4b767fefd804bfe02881c3015d4b14f/app/javascript/application.js#L5 As it described in docs - I need only to pin flowbite to importmap.rb and to add it to application.js |
The Flowbite specific css file is not in your repo. It needs to be there. Here’s a simple way to do it. tl;dw Download the latest CDN versions of the Put the Add flowbite to the
Add flowbite to the
In the module.exports = {
darkMode: "class", //add this line
content: [
//all the default stuff here
]
} Add the stylesheet to
Bonus: download the markdown files from the flowbite repo where it describes each component. That way, you have context for AI coding help or just your own documentation in your IDE |
@bitshaker I've checked this video and, you know, it goes against almost all rails principles. But, anyway, let's check docs, I've mentioned earlier. If you clone my repo and check it - you'll see that everything done following this guide. Also, you can add any code sample from flowbite docs and everything work fine, except backdrop. But, ok, forget my repo, let's check rails guides - https://guides.rubyonrails.org/asset_pipeline.html Everytime you pin any package - it is downloaded to vendor/javascript folder for some reason (offline access, prevent from yanking from package hosting, etc.). So, we need to create a separate package for flowbite.turbo. Also, I've found following issue rails/importmap-rails#80 - with importmaps it is impossible to pin CSS. That's why the author of your video have downloaded flowbite.turbo.js and css to vendor folder. As I said - it isn't a rails way, but a workaround. I have an idea - it is possible to publish ruby gem, which will make all required js/css available without importmaps. @zoltanszogyenyi what do you think? Dow you need my help with rubygem? |
Also, I've found the following gem https://github.com/iwdt/flowbite-rails but it looks abandoned |
I've checked again this video and there is another problem - author have imported tailwind 2 times - from app/assets/stylesheets/application.tailwind.css and from vendor/assets/stylesheets/flowbite.css I strongly recommend avoiding following such scheme. There are 2 working schemes:
I think that rubygem way is more accurate, because developers, who use flowbite, will receive updated assets without necessarily to update local files |
Agreed. If you know how to put a gem together, I’ll happily use it and help if I can. |
@bitshaker I'll try to do something this weekend |
I can confirm that this problem exists. |
Hey! I spent some time and I think I know what's wrong with backdrop. The problem occurs is because of tailwind do purgecss for unused classes and all those classes are listed in flowbite/plugin.js. There is a problem with flowbite plugin, it cannot be loaded with importmap. I've created a gem (but didn't publish yet because of plugin.js issue) which pins flowbite.turbo.js avoiding necessarily to pin flowbite to importmap.rb, but I haven't fixed an issue when I do put plugin.js locally and link it in tailwind.config.js :( But if you're strong in JavaScript I'll be appreciated for your help. |
Describe the bug
There are no backdrop in rails8 app using importmaps
To Reproduce
bundle install
bin/dev
The text was updated successfully, but these errors were encountered: