tweak: enable JS minification for non-debug mode
All checks were successful
Docker Build and Push / build-and-push (push) Successful in 1m14s
All checks were successful
Docker Build and Push / build-and-push (push) Successful in 1m14s
This commit is contained in:
18
app.py
18
app.py
@@ -14,20 +14,20 @@ app = Flask(__name__)
|
||||
|
||||
locales.ensure_loaded()
|
||||
|
||||
# CSS Compilation and minification
|
||||
if app.debug:
|
||||
# CSS Compilation and minification
|
||||
css = compile_sass(filename="static/style.scss", output_style="compressed")
|
||||
with open("static/style.css", "w", encoding="utf-8") as f:
|
||||
f.write(css)
|
||||
|
||||
# JS minification
|
||||
with open("static/script.js", encoding="utf-8") as f:
|
||||
js = f.read()
|
||||
js = re.sub(r"/\*.*?\*/", "", js, flags=re.S)
|
||||
js = re.sub(r"//.*", "", js)
|
||||
js = re.sub(r"\s+", " ", js).strip()
|
||||
with open("static/script.min.js", "w", encoding="utf-8") as f:
|
||||
f.write(js)
|
||||
# JS minification
|
||||
with open("static/script.js", encoding="utf-8") as f:
|
||||
js = f.read()
|
||||
js = re.sub(r"/\*.*?\*/", "", js, flags=re.S)
|
||||
js = re.sub(r"//.*", "", js)
|
||||
js = re.sub(r"\s+", " ", js).strip()
|
||||
with open("static/script.min.js", "w", encoding="utf-8") as f:
|
||||
f.write(js)
|
||||
|
||||
|
||||
@app.before_request
|
||||
|
||||
Reference in New Issue
Block a user