您是否在版本控制中添加了公共/资产? [英] Do you add public/assets in version control?

查看:49
本文介绍了您是否在版本控制中添加了公共/资产?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在rails 3.1中,当您预编译资产时,rails创建public/assets目录并在其中添加文件.

In rails 3.1, when you precompile the assets, rails create public/assets directory and add files there.

您是否对public/assets/*进行版本控制?

Do you version-control public/assets/*?

推荐答案

我也在寻找答案.我发现官方的《 Rails指南》对此有一些想法:

I was looking for an answer to this too. I found the official Rails Guide has some thoughts on this:

http://guides.rubyonrails.org/asset_pipeline.html#local-precompilation

以下是相关部分的引号(加了强调):

Here's a quote of the relevant section (emphasis added):

您可能要在本地预编译资产的原因有很多.其中包括:

There are several reasons why you might want to precompile your assets locally. Among them are:

  • 您可能没有对生产文件系统的写权限.
  • 您可能要部署到多个服务器上,并希望避免重复工作.
  • 您可能正在进行不包含资产变更的频繁部署.
  • You may not have write access to your production file system.
  • You may be deploying to more than one server, and want to avoid duplication of work.
  • You may be doing frequent deploys that do not include asset changes.

本地编译允许您将编译后的文件提交到源代码管理中,并按常规进行部署.

Local compilation allows you to commit the compiled files into source control, and deploy as normal.

有三个警告:

  • 您不得运行预编译资产的Capistrano部署任务.
  • 您必须确保开发系统上有任何必要的压缩器或压缩器.
  • 您必须更改以下应用程序配置设置:
  • You must not run the Capistrano deployment task that precompiles assets.
  • You must ensure any necessary compressors or minifiers are available on your development system.
  • You must change the following application configuration setting:

config/environments/development.rb中,放置以下行:

config.assets.prefix = "/dev-assets"

prefix更改使Sprockets使用不同的URL在开发模式下为资产提供服务,并将所有请求传递给Sprockets.在生产环境中,前缀仍设置为/assets.如果没有此更改,该应用程序将为开发中的/assets中的预编译资产提供服务,并且您将看不到任何本地更改,除非您再次编译资产.

The prefix change makes Sprockets use a different URL for serving assets in development mode, and pass all requests to Sprockets. The prefix is still set to /assets in the production environment. Without this change, the application would serve the precompiled assets from /assets in development, and you would not see any local changes until you compile assets again.

在实践中,这将允许您在本地进行预编译,将这些文件保存在工作树中,并在需要时将这些文件提交给源代码管理.开发模式将按预期工作.

In practice, this will allow you to precompile locally, have those files in your working tree, and commit those files to source control when needed. Development mode will work as expected.

因此,偶尔将预编译的资产放入VCS似乎是一个好主意.

So, it looks like it might be a good idea to put precompiled assets into VCS on occasion.

这篇关于您是否在版本控制中添加了公共/资产?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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