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

查看:34
本文介绍了究竟什么是“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?

推荐答案

这个选项的效果在 这篇文章,但我也会在这里总结一下.更改 config.assets.debug 的价值在于在开发中的页面加载时间和易于调试之间进行折衷.

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天全站免登陆