Rails 3.1+ 、资产管道和大型项目
我希望得到社区的意见和看法。
我正在开发一个具有多个模块的大型应用程序,它是一个基于内容的网站,还需要许多独特的 UI 功能。
我喜欢使用 SASS 和 Coffee-script,但我想听听您的意见的原因是,我们需要编译资产,在我的 Core-i3 机器上需要 15-20 分钟。因为我们也使用 bootstrap
和 compass-rails
。
我的问题是,在我们必须处理大量 CSS 且 UI/CSS 不断更新的情况下使用 Asset pipeline 是否正确。由于每次 css 更改都是实时进行的,因此我们必须编译资源并且需要很长时间。
对于如此庞大的项目,我们使用正常的 Rails 3 样式和脚本功能来避免资产管道的复杂性是否可行?或者我们可以通过什么方法来降低它的复杂性并减少编译时间。
请详细提供您的意见,以便此问题/答案可以作为其他人在决定资产管道之前的指南。
I want opinion and views from community.
I am developing a large application with multiple modules, Its a content based website which need many unique UI features as well.
I love to use SASS and coffee-script, but the reason i want your opinion is that, we need to compile the assets and on my Core-i3 machine it takes 15-20 minutes. Since we are using bootstrap
, and compass-rails
as well.
My point of question is, Is it right to use Asset pipeline where we have to deal with huge CSS and where we have constant update in the UI/CSS. Since for each css change we go for live, we have to compile the assets and takes a very long time.
Is it no feasible that we use normal Rails 3 styling and scripting features to avoid complexity of asset-pipeline for such a huge project. Or what would be the ways that we can reduce the complexity of it and reduce that compiling time.
Please provide your opinions in detail, so that this question/answers server as a guideline for other people before deciding on assets pipeline.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现您有三个选择:
1. 完全禁用资产管道
这种方法可能是最容易采用的配置方法:您可以禁用资产管道并回退到直接在 CSS + Javascript 中继续开发。就我个人而言,我认为 Coffeescript 和 SCSS 可以带来巨大的生产力提升,让我的生活变得更轻松,所以我不会走这条路。但这是一种可能性。
要禁用资产管道,您需要设置以下配置选项:
并从 gemfile 中删除资产组中的 gem:
2. 在生产中启用资产管道
通常不推荐,但也是一个选项:取决于您的服务器负载和数量用户,可以在启用资产管道的情况下在生产中运行应用程序。当然,这种方法的缺点是,每次收到请求时,服务器都必须重新编译资源。
3. 获得更快的机器(如果可能的话,配备 SSD)
与开发人员的时间成本相比,计算机确实非常便宜,所以如果可能的话我会建议买一台更好的带有固态硬盘的机器。使用 SSD 后,不仅可以节省时间,而且 IO 密集型操作(例如运行测试套件或编译资产)也会大大减少。
I see that you have three options:
1. Disable the asset pipeline completely
This approach might be the easiest to take configuration-wise: you could disable the asset pipeline and fall back to continue developing directly in CSS + Javascript. Personally, I see Coffeescript and SCSS as huge productivy gains, that make my life easier, so I would not take this route. But it's a possibility.
To disable the asset pipeline you need to set the following config option:
And remove the gems in the assets group from your gemfile:
2. Enable the asset pipeline in production
Usually not recommended but also an option: depending on your server load and amount of users, it might be possible to run an application in production with the asset pipeline enabled. The downside of this approach is of course that the server must recompile the assets everytime a request comes in.
3. Get a faster machine (with an SSD if possible)
A computer is really really cheap compared with the amount of money a developer's time costs, so if possible I would recommend to get a better machine with a solid state disk. Not only you will save time, but IO intensive operations like running test suites or compiling assets are drastically reduced when going SSD.