More precise CSS optimization.
This commit is contained in:
parent
784ba35f36
commit
76a61f69e0
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue