admin管理员组文章数量:1123377
The stack is: RoR 8 + turbo-rails + propshaft + importmaps-rails + tailwindcss-rails + Flowbite.
I have completed the integration steps from the Flowbite guide to add Flowbite to my Rails app. At first glance it worked, but I've found that I can't import anything from the Flowbite in a Stimulus controller, e.g. when I'm trying to import Dismiss:
// app/javascript/controllers/toasts_controller.js
import { Controller } from "@hotwired/stimulus";
import { Dismiss } from "flowbite";
export default class extends Controller {
connect() {
}
}
This fails with the following error:
Failed to register controller: toasts (controllers/toasts_controller) SyntaxError: The requested module 'http://localhost:3000/assets/flowbite.turbo.min-[hash].js' doesn't provide an export named: 'Dismiss'
The same error occurs with the import { Datepicker } from 'flowbite';
, etc..
It seems that Flowbite has long-lasting troubles when paired with Turbo (see this issue). I also found a very similar issue, but I couldn't grasp the proposed solution.
The versions are:
$ rails -v
Rails 8.0.1
$ npm list flowbite
[email protected] /path-to-my-app/node_modules/flowbite
My app/config/tailwind.config.js
file:
const defaultTheme = require('tailwindcss/defaultTheme')
module.exports = {
darkMode: 'selector',
content: [
'./public/*.html',
'./app/helpers/**/*.rb',
'./app/javascript/**/*.js',
'./app/views/**/*.{erb,haml,html,slim}',
'./node_modules/flowbite/**/*.js'
],
theme: {
extend: {
fontFamily: {
sans: ['Inter var', ...defaultTheme.fontFamily.sans],
},
},
},
plugins: [
require('flowbite/plugin'),
require('@tailwindcss/forms'),
require('@tailwindcss/typography'),
require('@tailwindcss/container-queries'),
]
}
Any help would be much appreciated.
本文标签:
版权声明:本文标题:stimulusjs - Can't import anything from the Flowbite lib in a Rails 8 app (module 'flowbite.turbo.min.js' 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736565902a1944703.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论