In my Django project, I have carefully organized the templates so that each page includes a "common" LESS file along with an additional LESS file for page-specific styles.
The challenge arises when I want the page-specific LESS file to access variables from the "common" LESS file. My initial thought was to create a separate file for variable declarations and import it into both LESS files.
However, due to the structure of Django apps using separate directories for static files, the filesystem ends up looking like this:
common.less
andother.less
need to importdefinitions.less
. Forcommon.less
, the import statement is straightforward:@import "definitions.less";
Here is how the LESS files are included on the page:
{% load compress %} {% load static %} {% compress css %} <link href="{% static "css/common.less" %}" rel="stylesheet" type="text/less"> {% endcompress %}
What would be the most efficient way to ensure that common variable definitions are accessible to both LESS files? I aim to avoid merging the LESS files for reasons such as maintaining loose-coupling and minimizing data retrieval for individual pages.
- Removing the ability to deactivate an app without affecting the rest of the site.
- Increasing the amount of data fetched for a single page by including all styles for all apps.