mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
refactor project structure
This commit is contained in:
31
web/compress-uis.sh
Executable file
31
web/compress-uis.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||
|
||||
set -e
|
||||
|
||||
STATIC_DIR=dist/static/$1
|
||||
RAW_DIR=dist/raw/$1
|
||||
|
||||
mkdir -p $STATIC_DIR
|
||||
rm -rf $STATIC_DIR
|
||||
|
||||
if ! [[ "$ENVIRONMENT" =~ (^|-)dev($|-) ]]; then
|
||||
find $RAW_DIR -type f -not -name '*.gz' -and -not -name '*.br' | xargs -n 1 -P 0 gzip -kf
|
||||
find $RAW_DIR -type f -not -name '*.gz' -and -not -name '*.br' | xargs -n 1 -P 0 brotli -kf
|
||||
|
||||
for file in $(find $RAW_DIR -type f -not -name '*.gz' -and -not -name '*.br'); do
|
||||
raw_size=$(du $file | awk '{print $1 * 512}')
|
||||
gz_size=$(du $file.gz | awk '{print $1 * 512}')
|
||||
br_size=$(du $file.br | awk '{print $1 * 512}')
|
||||
if [ $((gz_size * 100 / raw_size)) -gt 70 ]; then
|
||||
rm $file.gz
|
||||
fi
|
||||
if [ $((br_size * 100 / raw_size)) -gt 70 ]; then
|
||||
rm $file.br
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
cp -r $RAW_DIR $STATIC_DIR
|
||||
Reference in New Issue
Block a user