swh:1:snp:4e3e7077647a709f15b8c1b32ce7100175d0580b
Tip revision: 6b5a5fe85b64da3ca5e4c383c8f7b7b475fdfb48 authored by Jean Kossaifi on 15 October 2020, 18:31:27 UTC
Update website + API fix
Update website + API fix
Tip revision: 6b5a5fe
minify.py
from slimit import minify
from rcssmin import cssmin
from pathlib import Path
asset_path = Path('./themes/tensorly/static')
for path in asset_path.glob('*.js'):
# Ignore already minified files
if '.min.' in str(path):
continue
target_path = path.with_suffix('.min.js')
with open(path.as_posix(), 'r') as f:
text = f.read()
minified = minify(text, mangle=True, mangle_toplevel=True)
with open(target_path.as_posix(), 'w') as f:
f.write(minified)
for path in asset_path.glob('*.css'):
# Ignore already minified files
if '.min.' in str(path):
continue
target_path = path.with_suffix('.min.css')
with open(path.as_posix(), 'r') as f:
text = f.read()
minified = cssmin(text)
with open(target_path.as_posix(), 'w') as f:
f.write(minified)