Skip to content

Instantly share code, notes, and snippets.

@kemsakurai
Last active September 20, 2018 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kemsakurai/9487304b1fb9ed9447fbd8a897c45cc0 to your computer and use it in GitHub Desktop.
Save kemsakurai/9487304b1fb9ed9447fbd8a897c45cc0 to your computer and use it in GitHub Desktop.
サイトの全てのHTML に uncss cssbeautify-cli を実行するスクリプト
#!/bin/bash
DOMAIN='www.yourdomain.com'
# toppageから、category page、archivepage のcache を作成
wget -q https://$DOMAIN --no-cache -O - | egrep -o "/blog/category/[^\"]+|/blog/archive/[^\"]+|/about[^\"]+|/blog/feeds/[^\"]+" | sed "s/'/'/g" | sort | uniq | while read line;
do
filename=$(echo "$line"| sed 's/\///g')
# loadCSS を使用している影響でcss が読み込めなかったので、uncss 対象のcss を直接指定
echo 'uncss '"https://$DOMAIN""'""$line""'"' -t 5000 -s https://$DOMAIN/static/CACHE/css/690a0d57c104.css | cssbeautify-cli -s > '"'""$filename"".css'"
done
#!/bin/bash
DOMAIN='www.yourdomain.com'
wget -q https://$DOMAIN/sitemap.xml --no-cache -O - | egrep -o "https://$DOMAIN[^<]+" | sed "s/&#39;/'/g" | while read line;
do
filename=$(echo "$line"| sed 's/\///g')
# loadCSS を使用している影響でcss が読み込めなかったので、uncss 対象のcss を直接指定
echo 'uncss '"'""$line""'"' -t 5000 -s https://$DOMAIN/static/CACHE/css/690a0d57c104.css | cssbeautify-cli -s > '"'""$filename"".css'" >> css
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment