diff --git a/bookwyrm/management/commands/compile_themes.py b/bookwyrm/management/commands/compile_themes.py
new file mode 100644
index 000000000..95c6699ba
--- /dev/null
+++ b/bookwyrm/management/commands/compile_themes.py
@@ -0,0 +1,48 @@
+""" Our own command to all scss themes """
+import glob
+import os
+
+import sass
+
+from django.core.management.base import BaseCommand
+
+from sass_processor.apps import APPS_INCLUDE_DIRS
+from sass_processor.processor import SassProcessor
+from sass_processor.utils import get_custom_functions
+
+from bookwyrm import settings
+
+
+class Command(BaseCommand):
+ """command-line options"""
+
+ help = "SCSS compile all BookWyrm themes"
+
+ # pylint: disable=unused-argument
+ def handle(self, *args, **options):
+ """compile"""
+ themes_dir = os.path.join(
+ settings.BASE_DIR, "bookwyrm", "static", "css", "themes", "*.scss"
+ )
+ for theme_scss in glob.glob(themes_dir):
+ basename, _ = os.path.splitext(theme_scss)
+ theme_css = f"{basename}.css"
+ self.compile_sass(theme_scss, theme_css)
+
+ def compile_sass(self, sass_path, css_path):
+ compile_kwargs = {
+ "filename": sass_path,
+ "include_paths": SassProcessor.include_paths + APPS_INCLUDE_DIRS,
+ "custom_functions": get_custom_functions(),
+ "precision": getattr(settings, "SASS_PRECISION", 8),
+ "output_style": getattr(
+ settings,
+ "SASS_OUTPUT_STYLE",
+ "nested" if settings.DEBUG else "compressed",
+ ),
+ }
+
+ content = sass.compile(**compile_kwargs)
+ with open(css_path, "w") as f:
+ f.write(content)
+ self.stdout.write("Compiled SASS/SCSS file: '{0}'\n".format(sass_path))
diff --git a/bookwyrm/settings.py b/bookwyrm/settings.py
index 0780f8c54..d960c6071 100644
--- a/bookwyrm/settings.py
+++ b/bookwyrm/settings.py
@@ -193,7 +193,8 @@ STATICFILES_FINDERS = [
]
SASS_PROCESSOR_INCLUDE_FILE_PATTERN = r"^.+\.[s]{0,1}(?:a|c)ss$"
-SASS_PROCESSOR_ENABLED = True
+# when debug is disabled, make sure to compile themes once with `./bw-dev compile_themes`
+SASS_PROCESSOR_ENABLED = DEBUG
# minify css is production but not dev
if not DEBUG:
diff --git a/bookwyrm/templates/settings/themes.html b/bookwyrm/templates/settings/themes.html
index 628b04d77..c0dfd7b42 100644
--- a/bookwyrm/templates/settings/themes.html
+++ b/bookwyrm/templates/settings/themes.html
@@ -29,7 +29,7 @@
{% trans "Copy the theme file into the bookwyrm/static/css/themes
directory on your server from the command line." %}
./bw-dev collectstatic
." %}
+ {% trans "Run ./bw-dev compile_themes
and ./bw-dev collectstatic
." %}