[openstreetmap/openstreetmap-website] Sprockets vs optional config files (#2185)

Andy Allan notifications at github.com
Wed Mar 20 10:54:26 UTC 2019


In [app/assets/javascripts/osm.js.erb](https://github.com/openstreetmap/openstreetmap-website/blob/53cc1d2d11d358c171ee5beab55a3d20b79e9dab/app/assets/javascripts/osm.js.erb) we need to tell sprockets to recompile the output whenever the settings change. To do this we mark that file as depending on `config/settings.yml` and `config/settings.local.yml`.

However, this throws up two problems:

* `settings.local.yml` is supposed to be optional, but Sprockets throws an error if the file can't be found.
* The config gem also supports a [bunch of other files](https://github.com/railsconfig/config/blob/3a28b646a69c16f87d6539b4e1c4189aecb34c84/lib/config.rb#L60-L70), which should also trigger a recompile if they exist and then get changed.

I've checked through the sprockets documentation, but I can't see any obvious guidance for approaches to this situation.

Potential solutions include:

* Remove the dependency on `settings.local.yml`. This will make the 'out-of-the-box' situation better for developers, but could lead to problems later on when changes to that file are not reflected in the compiled javascript (without manual asset recompilation).
* Ask the upstream sprockets developers what they think about depending on optional files, or if they have any suggestions.
* Create an initializer which outputs the computed settings to a file, and depend on that output file instead.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/issues/2185
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20190320/984255eb/attachment.html>


More information about the rails-dev mailing list