Skip to content
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

Using flowbite with assets-mapper #61

Open
LyamD opened this issue Jul 10, 2024 · 2 comments
Open

Using flowbite with assets-mapper #61

LyamD opened this issue Jul 10, 2024 · 2 comments

Comments

@LyamD
Copy link

LyamD commented Jul 10, 2024

Hi, I'm trying to use the flowbite plugin with Symfony 7, assets-mapper and the tailwind-bundle.

I can't get the JS of flowbite to work. I've followed line by line the Symfony documentation, restarted the project from scratch, also tried the few tricks from this issue: #36

No matter how I import ("flowbite/plugin", "flowbite/plugin.js", full path), and I think i've tried every combination possible within app.js, tailwind.config.js and importmap.php, but it is still not working.

I don't have any js console errors, custom js and css are loaded, but none of the flowbite component are working.

What am I missing ? Is it still possible to do it ?

@bocharsky-bw
Copy link
Member

Hm, the import path should be relative, it depends on where the file is located in which you're trying to include that flowbite. But IIRC you need to import the main flowbite package:

// The path should be correct only if you're in assets/app.js, otherwise change it correspondively
import '../vendor/flowbite/flowbite.js';

And I think in your tailwind.config.js it should be something like:

module.exports = {
  content: [
    './templates/**/*.html.twig',
    './assets/**/*.js',
    './assets/vendor/flowbite/**/*.js',
  ],
  theme: {
    extend: {},
  },
  plugins: [
    require('./assets/vendor/flowbite/plugin'),
  ],
};

And in importmap.php:

return [
    'imports' => [
        'flowbite' => 'assets/vendor/flowbite/flowbite.js',
    ],
];

I hope that helps!

@luisibal
Copy link

luisibal commented Jan 9, 2025

Just a follow up, I left this message in the other thread:

I was struggling with this but the 'Solution' is not use the flowbite like this:

module.exports = {

    plugins: [
        require('flowbite/plugin')
    ]

}

Since this requires installing it with npm/ pnpm etc. and then flowbite/plugin looks up in the node_modules folder, that's why we get an error with AssetMapper because it doesn't use a node_modules folder. Using it like that was only one of the ways to use flowbite mentioned in the documentation.

https://flowbite.com/docs/getting-started/quickstart/

but simple use like this:

import 'flowbite';

in your js file where you want to use it and you can still configure tailwind the usual way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants