1
0
Fork 0
mirror of https://github.com/Findus23/acronomy.git synced 2024-09-19 15:33:45 +02:00
acronomy/acros/utils/assets.py

31 lines
829 B
Python
Raw Permalink Normal View History

2020-06-13 21:18:58 +02:00
from pathlib import Path
import sass
basedir = Path(__file__).resolve().parent.parent.parent
inputdir = basedir / "static/scss/"
inputfile = inputdir / "main.scss"
outputfile = basedir / "static/css/main.css"
sourcemap = outputfile.with_suffix(".css.map")
def get_css(debug=False):
sourcemap_name = "css_sourcemap" if debug else str(sourcemap)
css, sourcemap_text = sass.compile(
filename=str(inputfile),
2020-07-29 14:48:00 +02:00
output_style="nested" if debug else "compressed",
2020-06-13 21:18:58 +02:00
include_paths=[str(inputdir), str(basedir)],
source_map_filename=sourcemap_name,
2020-06-15 19:43:42 +02:00
source_map_contents=True
2020-06-13 21:18:58 +02:00
)
return css, sourcemap_text
def save_css():
css, sourcemap_text = get_css()
with outputfile.open("w") as f:
f.write(css)
with sourcemap.open("w") as f:
f.write(sourcemap_text)