Skip to content

Instantly share code, notes, and snippets.

@kimiamania
Last active December 28, 2015 21:49
Show Gist options
  • Save kimiamania/7567739 to your computer and use it in GitHub Desktop.
Save kimiamania/7567739 to your computer and use it in GitHub Desktop.
import cssmin, time, glob
#nama file output, disini gue beri nama all_UnixTime.css
#contoh file output all_1376637310.css
outfilename = 'all_' + str((int(time.time()))) + ".css"
#membaca setiap file css dalam 1 folder
with open(outfilename, 'wb') as outfile:
for fname in glob.glob('*.css'):
with open(fname, 'r') as rawfile:
#mengecilkan css
minified_file = cssmin.cssmin(rawfile.read())
#menulis css yang sudah diperkecil ke file output
outfile.write(minified_file)
outfile.write('/* ================================end of ' + fname + '===========================================*/\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment