Closed zobweyt closed 1 year ago
With the current implementation, you can specify an input directory and output directory, and all scss/sass files in that directory will be compiled.
The logic is here, feel free to make a pull request if you need additional functionality: https://github.com/coderedcorp/django-sass/blob/16fbb498ae4cd9cbcc00a07be3e27d4c9080c161/django_sass/__init__.py#L75-L112
I've reached this that way:
ignore_patterns = ["node_modules", "_*.scss"]
scss_files = []
# Find scss files
for finder in get_finders():
for path, storage in finder.list(ignore_patterns):
if path.endswith(".scss"):
fullpath = finder.find(path)
scss_files.append(fullpath)
# Compile each file
for scss_file in scss_files:
path = Path(scss_file)
css_file = os.path.join(path.parent.parent, f"dist\\css\\{path.stem}.min.css")
compile_sass(
inpath=scss_file,
outpath=css_file,
output_style="compressed",
precision=8,
)
Also would be nice to have ignore_patterns = []
parameter here:
https://github.com/coderedcorp/django-sass/blob/16fbb498ae4cd9cbcc00a07be3e27d4c9080c161/django_sass/__init__.py#L25
Because of this, it will be possible to exclude folders or files:
scss_files = find_static_scss(ignore_patterns=["node_modules", "_*.scss"])
Glad you found a solution. Feel free to make a pull request if you want to add your functionality to the package!
I would like to compile all files at once (with exclude folders) not separately for applications.