Files
discourse/app/controllers/bootstrap_controller.rb
David Taylor 4d0a817f40 DEV: Compile 'common' CSS into own assets (#31416)
Previously we were compiling core and theme CSS into two targets:
Desktop and Mobile. The majority of both files was the 'common' css.
This commit splits those common styles into their own targets so that
there is less duplication. This should improve compilation times + cache
reuse, as well as opening the door for experiments with
media-query-based mobile-modes.

The only functional change is that we can no longer use `@extend` to
copy 'common' rules in core to mobile/desktop. This is probably for the
best. Duplication and/or mixins are a more native-css pattern for this.

Plugins already have a common / mobile / desktop pattern, so are
unchanged by this commit.
2025-05-01 10:44:49 +01:00

33 lines
828 B
Ruby

# frozen_string_literal: true
class BootstrapController < ApplicationController
skip_before_action :redirect_to_login_if_required, :check_xhr
def plugin_css_for_tests
targets = Discourse.find_plugin_css_assets(include_disabled: true, desktop_view: true)
render_css_for_tests(targets)
end
def core_css_for_tests
targets = %w[color_definitions common desktop admin]
render_css_for_tests(targets)
end
private
def render_css_for_tests(targets)
urls =
targets.map do |target|
details = Stylesheet::Manager.new().stylesheet_details(target, "all")
details[0][:new_href]
end
stylesheet = <<~CSS
/* For use in tests only */
#{urls.map { |url| "@import \"#{url}\";" }.join("\n")}
CSS
render plain: stylesheet, content_type: "text/css"
end
end