Created
June 7, 2018 13:37
-
-
Save drscream/83ed560ae8bcb8de0168bdb180c32005 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#You must supply atleast 1 arguement to the script | |
#this arguement MUST be the CSS or JS file to minify | |
if test $# -lt 1; then echo Usage $0 CSS-or-JS-file; exit 1; fi | |
#If the arguement is given with -raw in the file name than it will be removed and saved as the file name with out | |
the raw. | |
outfile=`echo $1 | sed -e "s|-raw.\(.*\)$|.\1|"` | |
if test "$1" = "$outfile"; then outfile=/dev/stdout; | |
else echo Minimising $1 and outputting to $outfile; | |
fi; | |
#This command removes comments from CSS and Javascript files using sed. | |
#Read the supplied README.txt for additional information | |
cat $1 | sed -e "s|/\*\(\\\\\)\?\*/|/~\1~/|g" -e "s|/\*[^*]*\*\+\([^/][^*]*\*\+\)*/||g" -e "s|\([^:/]\)//.*$|\1|" | |
-e "s|^//.*$||" | tr '\n' ' ' | sed -e "s|/\*[^*]*\*\+\([^/][^*]*\*\+\)*/||g" -e "s|/\~\(\\\\\)\?\~/|/*\1*/|g" -e | |
"s|\s\+| |g" -e "s| \([{;:,]\)|\1|g" -e "s|\([{;:,]\) |\1|g" > $outfile | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment