Rails 现在用 importmap + stimulus 这套技术栈有什么好用的组件库?

willx · January 03, 2025 · Last by stephen replied at January 16, 2025 · 598 hits

看了一圈,感觉还是 bootstrap 组件最全;stimulus-components 组件非常少;tailwind 很多库还是得依赖 node

把 stimulus 作为一个包装器,所有 js 库都可以包进去。

stimulus-components 很多组件就是基于这个方法。

Reply to Rei

现在难受的点是,用了 stimulus-components,stimulus 配合 importmap 的自动懒加载就没了

Reply to willx

我依赖好几个 npm 包,importmap 无法很好的支持,所以回到 esbuild 了。

Reply to Rei

请教一下是用的 SPA 吗?因为目前 rails 这套 esbuild/webpack/rollup 想做到给不同的页面加载不同的 JS 文件(懒加载)好麻烦,得一个个文件路径手写到 js 编译工具的配置里面。

还是说所有 js 都放一起,不做懒加载。

Reply to willx

application.js 打包到一起,某些库体积大又很少变的单独打包,例如 editor,chart。layout 里 include 几个 js 文件。

其实 DHH 即使推 nobuild 也是把所有 js 预加载,可以用浏览器调试看 https://app.hey.com/sign_in ,所有 js 都用了 modulepreload。importmap 默认设置也是 preload。

懒加载会导致交互延迟,体验不好。

https://github.com/layui/layui 感觉这个应该契合度很高

You need to Sign in before reply, if you don't have an account, please Sign up first.