究竟是什么"config.assets.debug"?设置吗? [英] What exactly "config.assets.debug" setting does?

查看:72
本文介绍了究竟是什么"config.assets.debug"?设置吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始开发简单的Rails应用程序.经过几个小时的工作,我注意到删除的CSS仍然以某种方式仍适用于网页.

I have started development of simple rails application. After several hours work I have notices that somehow the deleted css is still applied to the web pages.

为了解决该问题,我多次执行了以下操作:

In order to fix the issue I executed the following actions several times:

  1. 停止/启动服务器
  2. 使用Rails服务器
  3. 使用扭矩盒服务器
  4. 删除浏览器缓存

但没有任何变化.这很奇怪-应用了新的CSS定义,但是我删除的那些定义仍然存在.因此,我放弃了并决定创建新项目.

but nothing changes. It was very strange - the new css definitions were applied, but those that I have deleted were still there. So, I gave up and decided to create new project.

我已经设置了新项目(其脚手架与第一个相同),当我打开其中一个视图时,旧项目中的样式也被应用了.我决定再次查看 http://guides.rubyonrails.org/asset_pipeline.html 和找出设置

I have setup the new project (its scaffold is the same as the first one) and when I open one of the views, the styles from the old project were applied too. I have decided to look again into http://guides.rubyonrails.org/asset_pipeline.html and find out that setting

#Expands the lines which load the assets
config.assets.debug = false

解决了问题.但是这个选项到底在做什么?为什么在这种情况下应用旧项目css?

solves the issue. But what is this option doing exactly? Why the old projects css were applied when this was true?

推荐答案

This option's effect is well described in this post, but I'll summarize it here as well. The value of changing config.assets.debug lies in a compromise between page load time in development and ease of debugging.

基本:

config.assets.debug = true:资产是单独提供的,就像您在开发中看到的那样进行组织.诸如SASS或CoffeeScript之类的预处理语言仍将显示为它们的目标语言(分别为CSS和JS).

config.assets.debug = true: assets are served individually, organized just as you see them in development. Preprocessed languages like SASS or CoffeeScript will still show up as their target languages (i.e., CSS and JS, respectively).

config.assets.debug = false:资产被捆绑到application.cssapplication.js之类的文件中.错误堆栈跟踪可能不再具有正确的行号,并且更难将其映射回您的原始代码.

config.assets.debug = false: assets are bundled into files like application.css and application.js. Error stack traces will likely not have the correct line number any more and it is harder to map those back to your original code.

这篇关于究竟是什么"config.assets.debug"?设置吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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