Explicitly specify depend_on relationship between assets and config

This commit is contained in:
Sebastian Serth
2024-05-08 22:28:59 +03:00
committed by Sebastian Serth
parent 336519b21d
commit 65416934ea
2 changed files with 9 additions and 7 deletions

View File

@ -1,3 +1,9 @@
// Note: Directives are only processed if they come before any application code.
// Once you have a line that does not include a comment or whitespace then Sprockets will stop looking for directives.
// If you use a directive outside of the "header" of the document it will not do anything, and won't raise any errors.
// <% config_file = CodeOcean::Config.new(:code_ocean, erb: false) %>
//= depend_on <%= config_file.path.basename %>
var CodeOceanEditor = {
THEME: window.getCurrentTheme() === 'dark' ? 'ace/theme/tomorrow_night' : 'ace/theme/tomorrow',
@ -27,12 +33,7 @@ var CodeOceanEditor = {
lastCopyText: null,
<% @config ||= CodeOcean::Config.new(:code_ocean, erb: false).read %>
// Important notice: Changing the config values requires any content-wise
// modification for this file in the development environment. Lacking to do so
// will result in the old, server-side cached serving of this file even across
// server restarts!
sendEvents: <%= @config['codeocean_events'] ? @config['codeocean_events']['enabled'] : false %>,
sendEvents: <%= config_file.read['codeocean_events'] ? config_file.read['codeocean_events']['enabled'] : false %>,
eventURL: Routes.events_path(),
fileTypeURL: Routes.file_types_path(),

View File

@ -6,7 +6,8 @@
Rails.application.config.assets.version = '1.1'
# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
# We require the config directory to enable asset dependencies on CodeOcean::Config values (stored as YML files in `config`).
Rails.application.config.assets.paths << Rails.root.join('config')
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets