<commit_before><%
def svgo_data_uri(path, precision: 0)
  svgo = "node_modules/.bin/svgo"

  if File.exists?(svgo)
    asset = depend_on_asset(path)
   `#{svgo} -i #{asset.filename} -o - -p #{precision} --multipass --enable=removeViewBox --datauri=base64`
  else
    raise "svgo not installed, run `npm install`"
  end
end
%>

trix-toolbar .button_group button {
  &.bold::before { background-image: url(<%= svgo_data_uri('trix/images/bold.svg', precision: 1) %>); }
  &.italic::before { background-image: url(<%= svgo_data_uri('trix/images/italic.svg', precision: 1) %>); }
  &.link::before { background-image: url(<%= svgo_data_uri('trix/images/link.svg', precision: 2) %>); }
  &.strike::before { background-image: url(<%= svgo_data_uri('trix/images/strike.svg', precision: 2) %>); }
  &.quote::before { background-image: url(<%= svgo_data_uri('trix/images/quote.svg', precision: 0) %>); }
  &.code::before { background-image: url(<%= svgo_data_uri('trix/images/code.svg', precision: 1) %>); }
  &.bullets::before { background-image: url(<%= svgo_data_uri('trix/images/bullets.svg', precision: 0) %>); }
  &.numbers::before { background-image: url(<%= svgo_data_uri('trix/images/numbers.svg', precision: 1) %>); }
  &.block-level.decrease::before { background-image: url(<%= svgo_data_uri('trix/images/block_level_decrease.svg', precision: 1) %>); }
  &.block-level.increase::before { background-image: url(<%= svgo_data_uri('trix/images/block_level_increase.svg', precision: 1) %>); }
  &.undo::before { background-image: url(<%= svgo_data_uri('trix/images/undo.svg', precision: 1) %>); }
  &.redo::before { background-image: url(<%= svgo_data_uri('trix/images/redo.svg', precision: 1) %>); }
}
<commit_msg>Reduce CSS file size with non-base64'd data URIs. h/t @bbenezech<commit_after><%
def svgo_data_uri(path, precision: 0)
  svgo = "node_modules/.bin/svgo"

  if File.exists?(svgo)
    asset = depend_on_asset(path)
    uri = `#{svgo} -i #{asset.filename} -o - -p #{precision} --multipass --enable=removeViewBox --datauri=unenc`.chomp
    %Q('#{uri}')
  else
    raise "svgo not installed, run `npm install`"
  end
end
%>

trix-toolbar .button_group button {
  &.bold::before { background-image: url(<%= svgo_data_uri('trix/images/bold.svg', precision: 1) %>); }
  &.italic::before { background-image: url(<%= svgo_data_uri('trix/images/italic.svg', precision: 1) %>); }
  &.link::before { background-image: url(<%= svgo_data_uri('trix/images/link.svg', precision: 2) %>); }
  &.strike::before { background-image: url(<%= svgo_data_uri('trix/images/strike.svg', precision: 2) %>); }
  &.quote::before { background-image: url(<%= svgo_data_uri('trix/images/quote.svg', precision: 0) %>); }
  &.code::before { background-image: url(<%= svgo_data_uri('trix/images/code.svg', precision: 1) %>); }
  &.bullets::before { background-image: url(<%= svgo_data_uri('trix/images/bullets.svg', precision: 0) %>); }
  &.numbers::before { background-image: url(<%= svgo_data_uri('trix/images/numbers.svg', precision: 1) %>); }
  &.block-level.decrease::before { background-image: url(<%= svgo_data_uri('trix/images/block_level_decrease.svg', precision: 1) %>); }
  &.block-level.increase::before { background-image: url(<%= svgo_data_uri('trix/images/block_level_increase.svg', precision: 1) %>); }
  &.undo::before { background-image: url(<%= svgo_data_uri('trix/images/undo.svg', precision: 1) %>); }
  &.redo::before { background-image: url(<%= svgo_data_uri('trix/images/redo.svg', precision: 1) %>); }
}

{'fraction_non_alphanumeric': 0.21045117075956596, 'fraction_numerical': 0.008566533409480296, 'mean_word_length': 5.167253521126761, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '234806', 'n_tokens_mistral': 1403, 'n_tokens_neox': 1288, 'n_words': 221}