1
0
Fork 0
mirror of https://github.com/Findus23/acronomy.git synced 2024-09-19 15:33:45 +02:00
acronomy/acros/management/commands/scss.py
2020-06-02 20:10:37 +02:00

30 lines
897 B
Python

from pathlib import Path
import sass
from django.core.management.base import BaseCommand
class Command(BaseCommand):
help = 'compile scss'
def handle(self, *args, **kwargs):
basedir = Path(__file__).resolve().parent.parent.parent.parent
inputdir = basedir / "static/scss/"
inputfile = inputdir / "main.scss"
outputfile = basedir / "static/css/main.css"
sourcemap = outputfile.with_suffix(".css.map")
with inputfile.open() as f:
sass_text = f.read()
css,sourcemap_text = sass.compile(
filename=str(inputfile),
output_style="compressed",
include_paths=[str(inputdir), str(basedir)],
source_map_filename=str(sourcemap)
)
with outputfile.open("w") as f:
f.write(css)
with sourcemap.open("w") as f:
f.write(sourcemap_text)