mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 06:28:57 +08:00
FIX: add cache breaker for fonts
This is a temporary fix since fonts may be cached without CORS A larger scale change needed. Our long term solution here is to have the SCSS compilation pipeline take care of this by introducing some SCSS var that can be consumed in the various stylesheets. We do not want to write a file on boot
This commit is contained in:
parent
d49e96c6a3
commit
7b7357147e
|
@ -311,6 +311,17 @@ module Discourse
|
|||
|
||||
# Use discourse-fonts gem to symlink fonts and generate .scss file
|
||||
fonts_path = File.join(config.root, 'public/fonts')
|
||||
|
||||
# TODO cache breaker should be supplied from both the gem
|
||||
# and the app
|
||||
# we may want to keep a cache breaker in Discourse in case somehow
|
||||
# Discourse changes rules for the particular asset
|
||||
#
|
||||
# TODO this code should move to SCSS compilation pipeline, we can have the
|
||||
# font gem inject some variables into the SCSS that it can consume, instead of writing a file
|
||||
# on boot
|
||||
font_cache_breaker = "1"
|
||||
|
||||
Discourse::Utils.atomic_ln_s(DiscourseFonts.path_for_fonts, fonts_path)
|
||||
File.open(File.join(config.root, 'app/assets/stylesheets/common/fonts.scss'), 'w') do |file|
|
||||
DiscourseFonts.fonts.each do |font|
|
||||
|
@ -326,7 +337,7 @@ module Discourse
|
|||
file.write <<~EOF
|
||||
@font-face {
|
||||
font-family: #{font[:name]};
|
||||
src: asset-url("/fonts/#{variant[:filename]}") format("#{variant[:format]}");
|
||||
src: asset-url("/fonts/#{variant[:filename]}?#{font_cache_breaker}") format("#{variant[:format]}");
|
||||
font-weight: #{variant[:weight]};
|
||||
}
|
||||
EOF
|
||||
|
|
Loading…
Reference in New Issue
Block a user