Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add zipassets.sh to facilitate gzip_static use (#537)
- Loading branch information
Showing
4 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ controllers/config.go* | |
testing/ | ||
*.orig | ||
debug | ||
public/**/*.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
# | ||
# This script helps prepare pre-zipped static assets for use with reverse proxy | ||
# features like nginx's gzip_static. | ||
|
||
echo "Gzipping assets for use with gzip_static..." | ||
find ./public -type f -name "*.gz" -execdir rm {} \; | ||
# Use GNU parallel if it is installed. | ||
if [ -x "$(command -v parallel)" ]; then | ||
if [ -x "$(command -v 7za)" ]; then | ||
find ./public -type f -not -name "*.gz" | parallel --will-cite --bar 7za a -tgzip -mx=9 -mpass=13 {}.gz {} > /dev/null | ||
else | ||
find ./public -type f -not -name "*.gz" | parallel --will-cite --bar gzip -k9f {} > /dev/null | ||
fi | ||
elif [ -x "$(command -v 7za)" ]; then | ||
find ./public -type f -not -name "*.gz" -execdir 7za a -tgzip -mx=9 -mpass=13 {}.gz {} \; > /dev/null | ||
else | ||
find ./public -type f -not -name "*.gz" -execdir gzip -k9f {} \; > /dev/null | ||
fi | ||
|
||
# Clean up incompressible files. | ||
find ./public -type f -name "*.png.gz" -execdir rm {} \; | ||
find ./public -type f -name "*.eot.gz" -execdir rm {} \; | ||
find ./public -type f -name "*.gz.gz" -execdir rm {} \; | ||
find ./public -type f -name "*.woff*.gz" -execdir rm {} \; |