Rails 5“gemify”资产清单文件

更新

得到这个工作状态。 gem可以在这里找到: https : //github.com/jakehockey10/popcircle

原帖:

我试图将一个jquery插件“gemify”作为一种学习体验。 我正在使用的插件也依赖于jquery.easing ,因此在gem的vendor/assets/javascripts文件夹中,我同时拥有jquery.easing.js以及其他jquery插件。

这是我的gem的.rb文件的样子:

 require '/version' module  class Engine < ::Rails::Engine class Engine < ::Rails::Engine initializer '.assets.precompile' do |app| app.config.assets.precompile += %w( big_round.png one.png two.png three.png four.png five.png ) end end end 

这是gem的当前结构:

 . ├── bin │ ├── console │ └── setup ├── CODE_OF_CONDUCT.md ├── Gemfile ├── Gemfile.lock ├── lib │ ├──  │ │ └── version.rb │ └── .rb ├── LICENSE.txt ├── name_of_gem.gemspec ├── Rakefile ├── README.md ├── test │ ├── _test.rb │ └── test_helper.rb └── vendor └── assets └── javascripts ├── jquery.easing.js └── jquery..js 

在测试应用程序中使用gem时,我希望能够只需要像//= require 那样的gem,并且只需要在gem的vendor文件夹中同时拥有两个javascripts文件加载到测试应用程序的资产管道中。 但是,我必须在我的测试应用程序中//= require jquery.easing和其他文件。

有没有办法让我的gem捆绑这些资产在一起,而不是应用程序的开发人员必须单独要求这两个文件?

而不是在我的测试应用程序的application.js

 //= require jquery-easing.js //= require jquery..js 

我想让开发人员有机会在application.js说出这个:

 //= require