Do you add public/assets in version control?

做~自己de王妃 提交于 2019-12-08 15:48:53

问题


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

Do you version-control public/assets/*?


回答1:


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.

There are three caveats:

  • 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:

In config/environments/development.rb, place the following line:

config.assets.prefix = "/dev-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.

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




回答2:


I use Capistrano to deploy. The last step is compiling the assets. Nothing like that gets checked into version control.

https://github.com/capistrano/capistrano/wiki/Documentation-v2.x

Checking in compiled assets, .gz files/etc, will just clutter up version control.



来源:https://stackoverflow.com/questions/7561043/do-you-add-public-assets-in-version-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!