Skip to content

Instantly share code, notes, and snippets.

@mfr
Last active December 17, 2015 21:49
Show Gist options
  • Save mfr/5677238 to your computer and use it in GitHub Desktop.
Save mfr/5677238 to your computer and use it in GitHub Desktop.
embed woff files
#!/bin/bash
for f in *.css; do
grep -ioE "(url\(|src=)['\"]?[^)'\"]*" $f | grep -ioE "[^\"'(]*.\.(woff)" | while read l ; do
sed -i "s>$l>data:font/${l/[^.]*./};base64,`openssl enc -base64 -in $l| tr -d '\n'`>" $f ;
done;
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment