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

前端 未结 2 1526
挽巷
挽巷 2021-02-13 16:41

Situation

I use a gem that brings its own JavaScript and stylesheet assets. This gem uses a standard application.js and application.css manifest to require all its ass

2条回答
  •  死守一世寂寞
    2021-02-13 17:10

    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.

提交回复
热议问题