带链轮的 Rails 7,在开发中启用已编译 css 中的原始文件

发布于 2025-01-16 05:12:10 字数 249 浏览 0 评论 0原文

我刚刚使用 --css bootstrap 启动了一个新的 Rails 7 项目,但我发现使用 bin/dev 启动服务器,编译后的 css 不再(如以前的 Rails 版本中那样)输出注释以及文件的文件名和行号,在其中可以找到每个 scss 类定义。

实际上,我对新的 Rails 如何与 scss 和 css 一起使用感到相当困惑,似乎 css 根本没有被编译。我找不到任何好的资源来理解它是如何工作的。有什么建议吗?

谢谢,

I just started a new rails 7 project with --css bootstrap, but I'm finding that starting the server with bin/dev the compiled css does no longer (as in previous rails versions) output a comment with the file name and line number of the file where to find each scss class definition.

I'm actually rather confused on how the new rails works with scss and css, it doesn't seem that the css is compiled at all. I couldn't find any good resources for understanding how it works. any suggestions?

Thanks,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

别理我 2025-01-23 05:12:10

默认情况下,Sprockets 似乎不生成源映射。
您可以尝试打开此文件:
config/environments/development.rb

并添加以下行:
config.assets.debug = true

Sprockets doesn't seem to generate sourcemaps by default.
You can try opening up this file:
config/environments/development.rb

And adding the line:
config.assets.debug = true

丑疤怪 2025-01-23 05:12:10

din/dev 文件的内容是什么?

Rails 7 也摆脱了 webpack:

Webpacker 已经为 Rails 社区提供了五年多的服务
编译和捆绑 JavaScript 的桥梁。这座桥已经不复存在了
发布后大多数人在大多数情况下都需要
Rails 7. 现在我们对 JavaScript 有了三个很好的默认答案
2021+,因此我们将不再在官方中发展 Webpacker
轨道容量。

Rails 7 现在使用 importmaps,因此根据您的 gem 文件,您可能必须使用 css-bundling。调查一下 dartsass 以及 propshaft,它取代了他们未来考虑做的链轮,以获得更好的想法。

传动轴会取代链轮成为 Rails 的默认设置吗? 最有可能的是,
但链轮也需要在未来很长一段时间内得到支持。
许多应用程序和 gem 都是基于 Sprocket 功能构建的,它们
不会很快迁移。仍在研究兼容性问题。
目前这还属于 alpha 软件。

What are the contents of you din/dev file?

Also rails 7 got rid of webpack:

Webpacker has served the Rails community for over five years as a
bridge to compiled and bundled JavaScript. This bridge is no longer
needed for most people in most situations following the release of
Rails 7. We now have three great default answers to JavaScript in
2021+, and thus we will no longer be evolving Webpacker in an official
Rails capacity.

Rails 7 now uses importmaps, so depending on your gem file you might have to use css-bundling. Look into that and dartsass along with propshaft, which replaces sprockets which they are thinking about doing in the future, to get a better idea.

Will Propshaft replace Sprockets as the Rails default? Most likely,
but Sprockets need to be supported as well for a long time to come.
Plenty of apps and gems were built on Sprocket features, and they
won't be migrating soon. Still working out the compatibility story.
This is very much alpha software at the moment.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文