Rails assets:precompile only one asset?

北城余情 提交于 2020-01-02 06:35:32

问题


Currently we have a Rails application but I have one question regarding the assets precompilation.

Each time that I edit one file (stylesheet or javascript file), we have to run:
bundle exec rake assets:precompile
...and then upload everything again, even those files that didn't changed at all.

Is there a way to compile only the edited files and the manifest.yml file?

Thanks in advance.


回答1:


i also had such a question, googled a lot and found one gem called: guard-rails-assets

It compiles the assets within Rails 3.1 application whenever those change.

For example, you can do this:

# compile ONLY when something changes
guard 'rails-assets', :run_on => :change do
  watch(%r{^app/assets/.+$})
end

Check it out




回答2:


I think no and unneccessary because all js files are compiled to one file as and css files. If you changed only one file - you changed such combined files. But, if you want to update resource file such as images, I think, you may, only place it in right directory under public/accets



来源:https://stackoverflow.com/questions/9713464/rails-assetsprecompile-only-one-asset

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