开发模式下的Rails精简(编译)资产 [英] Rails Minified (Compiled) Assets in development mode

查看:71
本文介绍了开发模式下的Rails精简(编译)资产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Rails开发模式下以最小化(编译)形式呈现资产?

How do I get my assets rendered in their minified (compiled) form in Rails development mode?

我大约有几十个资产文件,由于它们是一个接一个地提供的,因此在开发页面加载之前,所有这些花费了很长时间.我相信如果让它们保持编译状态并从中获得服务,将会加快我的页面加载时间(我知道当我专门处理资产时这不是理想的选择).

I have about few dozens of asset files, and because they are served one after another it all takes pretty long before the page loads in development. I believe if I keep them compiled and getting served from that would speed up my page load time(I know this is not ideal when I am specifically working on assets).

这是布局中的样式和脚本标签

Here is my style and script tags in the layout

<%= stylesheet_link_tag 'all'  %>
<%= javascript_include_tag 'all' %>

我还跑过bundle exec rake assets:precompile:nondigest

但是我仍然看到资产是一个接一个地呈现的.请帮忙!

But I still see the assets being rendered one after another. Please help!

推荐答案

这很简单.
您只需要在config/environments/development.rb中添加/更改以下行

That's quite simple.
You only need to add/change the following line in your config/environments/development.rb

config.assets.debug = false

然后重新启动Rails服务器.

And restart your rails server.

这篇关于开发模式下的Rails精简(编译)资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆