- Create file named
rem.rb
within the theme root with the content ofshopify-change-rem-values-to-standard.rb
- Make the file executable via the Terminal command
chmod +x rem.rb
- Run
ruby rem.rb
Thanks to @eloyesp Shopify/dawn#969 (comment)
require 'bigdecimal' | |
def custom_round value | |
BigDecimal(value * 2, 2).to_f / 2 | |
end | |
Dir.glob('**/*.{css,liquid}').each do |file| | |
fixed_file_content = File.read(file).gsub(/(?<!\w)([\d\.]+)rem/) do | |
value_in_pixels = $1.to_f * 10 | |
value_in_standard_rems = value_in_pixels.to_f / 16 | |
"#{ custom_round(value_in_standard_rems) }rem" | |
end | |
File.write file, fixed_file_content | |
end |
rem.rb
within the theme root with the content of shopify-change-rem-values-to-standard.rb
chmod +x rem.rb
ruby rem.rb
Thanks to @eloyesp Shopify/dawn#969 (comment)