Problem/Motivation

We stumble on the case when we want to introduce new partial and both new partial and old partial are importing same sass partial with variables, like:

old sass file themes/bs_bootstrap/sass/components/floating-labels.scss:

@import "init";
@import "partials/floating-labels-vars";
@import "partials/floating-labels";

new sass files themes/bs_bootstrap/sass/components/floating-labels-outlined.scss:

@import "init";
@import "partials/floating-labels-vars";
@import "partials/floating-labels-outlined";

On theme update there is a part of code in _bs_base_update_sass_files() which tries to detect sass refactoring change when you move some @import definition from old file to a new file and if it detect that then it will remove @import statement from old file. This code exist (added in #3078120-4: Decouple support for navbar off-canvas and dropdown menus from basic navigation support) so we can introduce refactoring changes more easily in base themes, but in this case it does not work because it will remove also a line `@import "partials/floating-labels-vars";` from old existing sass file, and this is something we do not want in this case.

Related code in_bs_base_update_sass_files() for mentioned refactoring detection is already a bit complex, but the rest of a generator is not different... So lets try to introduce additional detection that is analyzing import target sass partial content and if it consist only of variables definitions or mixins or functions then let's not remove it.
This will add more complexity in the code, but it does make refactoring updates a lot easier. If this new addition or this code in general is making problems in future we will need to consider it to remove it and then handle refactoring changes in theme update functions.

CommentFileSizeAuthor
#2 generator-improvements-3257070-2.patch5.75 KBpivica
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pivica created an issue. See original summary.

pivica’s picture

Status: Active » Needs review
FileSize
5.75 KB

Here is a first patch try to improve this.

  • pivica committed f43e8fe on 8.x-1.x
    Issue #3257070 by pivica: Generator moving (refactoring) partials...
pivica’s picture

Status: Needs review » Fixed

Committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.