Django Static Precompiler provides template tags and filters to compile CoffeeScript, LiveScript, SASS / SCSS, LESS, Stylus, Babel and Handlebars. It works with both inline code and external files.
I'm trying to import a CSS file within Less using the following import:
@import (inline) "normalize.css/normalize.css";
The compile seems to run correctly when I probe into the files generated, but I get the following error, causing my tests to fail and the first load of my page to report that "normalize.css.less" is not found.
The full traceback:
Traceback (most recent call last):
File "/workspaces/adapt_docs/adapt/tests/test_middleware.py", line 46, in test_login_required_middleware_logged_in
response = client.get("/")
^^^^^^^^^^^^^^^
File "/home/vscode/.local/lib/python3.11/site-packages/django/test/client.py", line 927, in get
response = super().get(path, data=data, secure=secure, headers=headers, **extra)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vscode/.local/lib/python3.11/site-packages/django/test/client.py", line 457, in get
return self.generic(
^^^^^^^^^^^^^
File "/home/vscode/.local/lib/python3.11/site-packages/django/test/client.py", line 609, in generic
return self.request(**r)
^^^^^^^^^^^^^^^^^
File "/home/vscode/.local/lib/python3.11/site-packages/django/test/client.py", line 891, in request
self.check_exception(response)
File "/home/vscode/.local/lib/python3.11/site-packages/django/test/client.py", line 738, in check_exception
raise exc_value
File "/home/vscode/.local/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "/home/vscode/.local/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vscode/.local/lib/python3.11/site-packages/django/views/generic/base.py", line 104, in view
return self.dispatch(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vscode/.local/lib/python3.11/site-packages/django/views/generic/base.py", line 143, in dispatch
return handler(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspaces/adapt_docs/core/views/home.py", line 21, in get
return render(
^^^^^^^
File "/home/vscode/.local/lib/python3.11/site-packages/django/shortcuts.py", line 24, in render
content = loader.render_to_string(template_name, context, request, using=using)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vscode/.local/lib/python3.11/site-packages/django/template/loader.py", line 62, in render_to_string
return template.render(context, request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vscode/.local/lib/python3.11/site-packages/django/template/backends/django.py", line 61, in render
return self.template.render(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vscode/.local/lib/python3.11/site-packages/django/template/base.py", line 175, in render
return self._render(context)
^^^^^^^^^^^^^^^^^^^^^
File "/home/vscode/.local/lib/python3.11/site-packages/django/test/utils.py", line 112, in instrumented_test_render
return self.nodelist.render(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vscode/.local/lib/python3.11/site-packages/django/template/base.py", line 1005, in render
return SafeString("".join([node.render_annotated(context) for node in self]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vscode/.local/lib/python3.11/site-packages/django/template/base.py", line 1005, in <listcomp>
return SafeString("".join([node.render_annotated(context) for node in self]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vscode/.local/lib/python3.11/site-packages/django/template/base.py", line 966, in render_annotated
return self.render(context)
^^^^^^^^^^^^^^^^^^^^
File "/home/vscode/.local/lib/python3.11/site-packages/django/template/loader_tags.py", line 157, in render
return compiled_parent._render(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vscode/.local/lib/python3.11/site-packages/django/test/utils.py", line 112, in instrumented_test_render
return self.nodelist.render(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vscode/.local/lib/python3.11/site-packages/django/template/base.py", line 1005, in render
return SafeString("".join([node.render_annotated(context) for node in self]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vscode/.local/lib/python3.11/site-packages/django/template/base.py", line 1005, in <listcomp>
return SafeString("".join([node.render_annotated(context) for node in self]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vscode/.local/lib/python3.11/site-packages/django/template/base.py", line 966, in render_annotated
return self.render(context)
^^^^^^^^^^^^^^^^^^^^
File "/home/vscode/.local/lib/python3.11/site-packages/django/templatetags/static.py", line 116, in render
url = self.url(context)
^^^^^^^^^^^^^^^^^
File "/home/vscode/.local/lib/python3.11/site-packages/django/templatetags/static.py", line 112, in url
path = self.path.resolve(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vscode/.local/lib/python3.11/site-packages/django/template/base.py", line 742, in resolve
new_obj = func(obj, *arg_vals)
^^^^^^^^^^^^^^^^^^^^
File "/home/vscode/.local/lib/python3.11/site-packages/static_precompiler/templatetags/compile_static.py", line 16, in compile_filter
compiled = utils.compile_static(source_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vscode/.local/lib/python3.11/site-packages/static_precompiler/utils.py", line 81, in compile_static
return registry.get_compiler_by_path(path).compile(path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vscode/.local/lib/python3.11/site-packages/static_precompiler/compilers/base.py", line 164, in compile
self.update_dependencies(source_path, self.find_dependencies(source_path))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vscode/.local/lib/python3.11/site-packages/static_precompiler/compilers/less.py", line 154, in find_dependencies
import_path = self.locate_imported_file(source_dir, import_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vscode/.local/lib/python3.11/site-packages/static_precompiler/compilers/less.py", line 147, in locate_imported_file
raise exceptions.StaticCompilationError(f"Can't locate the imported file: {import_path}")
static_precompiler.exceptions.StaticCompilationError: Can't locate the imported file: normalize.css/normalize.css.less
I'm trying to import a CSS file within Less using the following import:
The compile seems to run correctly when I probe into the files generated, but I get the following error, causing my tests to fail and the first load of my page to report that "normalize.css.less" is not found.
The full traceback: