Kos*_*tas 8 ruby-on-rails-3 sprockets asset-pipeline
我有一个app/assets/javascripts/moufa.js.erb文件,用文件中的值填充config/moufa.yml.我想使用depend_onsprockets指令,以便每次更改yaml文件时,它都会重新编译js文件.
我们能够通过添加新指令来解决这个问题.该指令(将其放在config/initializers/sprockets.rb中)在config /目录中添加了对文件的依赖:
class Sprockets::DirectiveProcessor
def process_depend_on_config_directive(file)
path = File.expand_path(file, "#{Rails.root}/config")
context.depend_on(path)
end
end
Run Code Online (Sandbox Code Playgroud)