How to override single files from gem assets for assets:precompile?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 11:19:38

In the demo code you posted at on GitHub, your application.js has:

//= require any_gem

That does not bring in a directory, it brings in any_gem.js, which is the Gem's manifest file that brings in all of the Gem's JS files. If you do not want all of the files, then you need to change that to bring in only the files you want by listing them explicitly:

//= require ../../../vendor/assets/javascripts/any_gem/do_not_override.js

Then you can add back in all of your own JS files, including your overrides, with:

//= require_tree .

BTW, great job on creating the demo app! You're a role model for the kids.

In application.rb or production.rb, you can prepend or append more assets path.

config.assets.prepend_path 'vendor/assets/jquery'
config.assets.append_path 'vendor/assets/something'

References:

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