More precise CSS optimization.

This commit is contained in:
Sage Vaillancourt 2022-09-23 08:27:38 -04:00
parent 784ba35f36
commit 76a61f69e0
1 changed files with 2 additions and 2 deletions

View File

@ -17,10 +17,10 @@ def optimize_css():
static_dir = root + '/undercover/flaskr/static/'
css = open(static_dir + 'styles.css', 'r').read()
minified_with_comments = "".join(list(map(
lambda line: line if 'media' in line or 'padding' in line or 'transition' in line else line.replace(' ', ''),
lambda line: re.sub(r':\s*', ':', re.sub(r'^\s*', '', line)),
css.split('\n')
)))
minified = re.sub( r'/\*[\s\S]*?\*/', "", minified_with_comments)
minified = re.sub(r'/\*[\s\S]*?\*/', "", minified_with_comments)
minified_file = open(static_dir + 'styles_min.css', 'w')
minified_file.write(minified)
minified_file.close()