My public website https://www.chameth.com/
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

minify.sh 976B

12345678910111213141516171819202122232425262728
  1. #!/bin/bash
  2. set -uxeo pipefail
  3. # Compress all the CSS files together
  4. cat /tmp/site/res/css/*.css > "/tmp/css-concatted.css"
  5. yui-compressor "/tmp/css-concatted.css" > "/tmp/css-combined.css"
  6. # Generate a small hash to bust caches if the file changes
  7. HASH=`sha256sum /tmp/css-combined.css | cut -c -10`
  8. # Replace the old CSS with the new
  9. mv "/tmp/css-combined.css" "/tmp/site/res/stylesheet-$HASH.css"
  10. rm -rf "/tmp/site/res/css"
  11. # Replace the references in the HTML, then run tidy over it
  12. for file in $(find /tmp/site/ -name '*.html'); do
  13. sed -i "s#\"/res/css/style.css\"#\"/res/stylesheet-$HASH.css\"#g" "$file"
  14. sed -i '\#"/res/css/.*.css"#d' "$file"
  15. # Tidy exits if there are warnings, which there probably will be...
  16. tidy -q -i -w 120 -m --vertical-space yes --drop-empty-elements no "$file" || true
  17. done
  18. # Convert all images to WebP
  19. for file in $(find /tmp/site -name '*.jpg' -o -name '*.png' -o -name '*.jpeg'); do
  20. cwebp -m 6 -mt -o "$file.webp" -- "$file"
  21. done