Skip to content

[Question] Can you suggest a way to @import less code form a different app #749

Open
@camilotorresf

Description

@camilotorresf

Hi,

I'm migrating a project from Django 1.11 to 3.2, and also migrating django-pipeline from 1.6.9 to 2.0.6.
Now, we have many django apps and in one app I'm importing less (CSS compiler) code from another app:

in admin_main/static/admin_main/less/common.less, which is located inside the admin_main app I have

@import "../../common/third_party/bootstrap/less/variables";
@import "../../common/less/styles/flexbox.less";
@import "../../common/less/lib/spacing.less";
@import "../../common/less/lib/ng-animate.less"

All these 4 less files are located in the common app:
common/static/common/third_party/bootstrap/less/variables.less
common/static/common/less/styles/flexbox.less
common/static/common/less/lib/spacing.less
common/static/common/less/lib/ng-animate.less

The problem is when collecting statics and compiling admin_main/static/admin_main/less/common.less, lessc cannot find the imported files, because these files are in a complete different directory, and the relative paths cannot be found.

With django-pipeline 1.6.9 these files were found, because the file to process was not the project file, but the collected file inside my collectedstatic directory: deploy/admin/collectedstatic/admin_main/less/common.less, and of course the 4 imported files are also inside the collectedstatic directory, and all works, because lessc can find them in the same collectedstatic directory.

I have found that the problem was introduced by this commit:
63d1182
When I revert the commit it works as before. For now, I'm going to fork and use a customized version of django-pipeline.

I kindly ask: is it possible, and how do you suggest to solve these relative imports from a different Django application with the official django-pipeline package?

Is it OK to create a Pull Request to modify that commit and only use the project_infile when PIPELINE_COLLECTOR_ENABLED == False ?

Thank you for the time you can spend on this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions