37 lines
1.0 KiB
Bash
37 lines
1.0 KiB
Bash
|
#!/bin/bash
|
||
|
|
||
|
echo "Running UglifyJS"
|
||
|
JSIN="/data/in/js/"
|
||
|
JSOUT="/data/out/js"
|
||
|
uglifyjs-folder "$JSIN" -x ".js" -eo "$JSOUT"
|
||
|
|
||
|
echo "Running UglifyCSS"
|
||
|
CSSIN="/data/in/styles/"
|
||
|
CSSOUT="/data/out/styles"
|
||
|
|
||
|
cd $CSSIN
|
||
|
echo "Changed directory"
|
||
|
pwd
|
||
|
for f in *
|
||
|
do
|
||
|
if [ -f "$f" ]; then
|
||
|
uglifycss "$f" --output "$f";
|
||
|
fi
|
||
|
done
|
||
|
|
||
|
echo "Moving 'styles' to 'out'"
|
||
|
cp -r /data/in/styles /data/out/styles
|
||
|
|
||
|
echo "Running html-minifier-terser"
|
||
|
HTMLIN="/data/in/"
|
||
|
HTMLOUT="/data/out"
|
||
|
html-minifier-terser --collapse-whitespace --remove-comments --file-ext html --input-dir /data/in/ --output-dir /data/out/
|
||
|
|
||
|
echo "Moving JSON Manifest file from root to output"
|
||
|
cat /data/in/manifest.json | jq -c > /data/out/manifest.json
|
||
|
|
||
|
echo "Moving images folder from in/ to out/"
|
||
|
cp -r /data/in/images /data/out/images
|
||
|
|
||
|
echo "Running GZIP & Brotli on all HTML, JS, CSS, JSON & SVG files"
|
||
|
find /data/out -type f -name \*.html -or -name \*.js -or -name \*.css -or -name \*.json -or -name \*.svg -or -name \*.ttf | while read file; do gzip -k -9 $file; brotli -k -q 11 $file; done
|