如何将 Zurb Foundation 实施到 Rails 7?
我目前正在将 Rails 应用程序升级到 7。我只是测试了一段时间,然后我在 上遇到了问题基础导轨。我安装了它并遵循了除
将 Foundation 添加到您的 JS
似乎 Rails 7 的指令尚未更新。
因此,CSS 似乎工作正常,但是当尝试实现需要 javascript 的功能时,例如 显示,它将无法正常工作。
知道如何正确实施 Foundation to Rails 7 吗?
I'm currently upgrading my rails app to 7. I was just testing it for a while then I have issues on Foundation Rails. I installed it and followed all the steps except the
Add Foundation to your JS
It seems the instruction is not updated yet for rails 7.
As a result, the CSS seems to work alright but when trying to implement features that require javascript like Reveal, it won't work properly.
Any idea how to implement Foundation to Rails 7 properly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它死了,吉姆。
与几乎所有“宝石化资产”一样,foundation-rails gem 是为旧的 Sprockets 资产管道制作的,这是 Rails 5 中的默认设置,并且在现代版本的 Rails 中没有维护或相关。
在 Sprockets 最初引入时,将第三方 JavaScript 或 CSS 包包装在 Ruby gems 中的整个想法被认为是可接受的解决方案,但由于它依赖于维护人员更新 gems 只是为了推送新版本的前端包,所以它并没有过时。
Sprockets 本身的开发也已停止,甚至可能无法编译 Foundation 的现代版本(如果它使用较新的功能,例如仅在 Dart-Sass 中可用的模块系统)。
Rails 6 用基于 Node.js 的短命 Webpacker 取代了 Spockets。 Rails 6 还默认使用 Yarn 从 NPM 安装前端包。
Rails 7 采用了一种非常不同的方法:
Rails 7 并未提供有关如何管理前端包的单一答案。
相反,它只是具有连接各种系统的管道,您需要找到适合您要求的系统,例如通过 import-maps 链接到 CDN,jsbundling-rails 或(不寒而栗)下载基础并通过 Scout 之类的东西编译它。
就开发人员的便利性而言,这与 Rails 5 天“刚刚工作”(某种程度上)相比是一个巨大的倒退,但这种方法不再站得住脚。
It's dead, Jim.
The foundation-rails gem like almost all "gemmified assets" is made for the old Sprockets assets pipleline that was the default in Rails 5 and its not maintained or relevant in modern versions of Rails.
The whole idea of wrapping third party JavaScript or CSS packages in Ruby gems was a considered an accepatble solution back when Sprockets was originally introduced but has not aged well as its dependent on maintainers updating gems just to push new versions of the front-end package.
Development on Sprockets itself has also stopped and it may not even be able to compile modern versions of Foundation if it uses newer features like the module system thats only available in Dart-Sass.
Rails 6 replaced Spockets with the short-lived Node.js based Webpacker. Rails 6 also defaulted to using Yarn to install front end packages from NPM.
Rails 7 takes a very different approach:
Rails 7 isn't shipping with a single answer to how to manage front-end packages.
Instead it just has the plumbing to hook up a variety of systems and you need to find the system that works for your requirements such as linking to CDN's via import-maps, jsbundling-rails or (shudder) downloading foundation and compliling it via something like Scout.
In terms of developer convience is it a huge step back from the Rails 5 days when it "just worked" (kind of) but that approach was no longer tenable.
我找到了一种让它工作的方法
我没有找到的是在 scss 中通过 importmap 添加基础样式表的正确方法。我只是将它们全部粘贴到资产中并炸毁了我的存储库。但目前还有效。
jQuery
执行
./bin/importmap pin jquery --download
查看其他选项添加到
application.js
样式表
app/assets/stylesheets/foundation
_vendor
和scss
拖到新文件夹中@import "./foundation/scss/foundation";
和@include Foundation-everything();
到application.scss
* = require_tree .
和*= require_self
Javascript
./bin/importmap pin Foundation-sites --download
然后添加到
application.js
i found a way to get it working
what i not found is the correct way for adding the foundation stylesheets, in scss, by importmap. i just pasted them all into the assets and blowed up my repository. But it works for now.
jQuery
execute
./bin/importmap pin jquery --download
see other optionsadd to
application.js
Stylesheets
app/assets/stylesheets/foundation
_vendor
andscss
into the new folder@import "./foundation/scss/foundation";
and@include foundation-everything();
toapplication.scss
*= require_tree .
and*= require_self
Javascript
./bin/importmap pin foundation-sites --download
then add to
application.js
我走了另一条路
我喜欢粉底,我找到了Vite。
太棒了,它可以与新的 Turbo 配合使用。
最棒的是Vite HMR。
关于如何建立基金会和所有员工,我写了一篇教程
设置 Vite、Svelte ,惯性,刺激,Bootstrap /基础
I've gone another way
I like foundation and i found Vite.
So great and it works together with the new Turbo.
Greatest thing is the Vite HMR.
For how to setup foundation and all that staff together i wrote a tuorial
Setup Vite, Svelte, Inertia, Stimulus, Bootstrap / Foundation