Point Sprockets' `depend_on` directive to a no

2019-04-24 10:42发布

I have an app/assets/javascripts/moufa.js.erb file that gets populated with values from a config/moufa.yml file. I want to use the depend_on sprockets directive so that every time the yaml file gets changed, it recompiles the js file.

1条回答
再贱就再见
2楼-- · 2019-04-24 11:03

We were able to solve this by adding a new directive. This directive (put this in config/initializers/sprockets.rb) adds a dependency on a file in the config/ directory:

class Sprockets::DirectiveProcessor
  def process_depend_on_config_directive(file)
    path = File.expand_path(file, "#{Rails.root}/config")
    context.depend_on(path)
  end
end
查看更多
登录 后发表回答