Skip to content

Backend less-parser fails on files containing only mixins #3032

@homecoded

Description

@homecoded

In lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Less/Processor.php:88

if (trim($content) === '') {
    $errorMessage = PHP_EOL . self::ERROR_MESSAGE_PREFIX . PHP_EOL . $path;
    $this->logger->critical($errorMessage);

    throw new ContentProcessorException(new Phrase($errorMessage));
}

... the less processor checks if a file was compiled successfully by checking if the content is not an empty string.
If you include the less version of Twitter-Bootstrap into a theme or extenion the build process fails because of that.

explanation:

Magento tries to build all of the file separately. When it comes across a mixin file the result will be empty because all mixins are resolved to an empty string by the less parser. See vendor/oyejorge/less.php/lib/Less/Visitor/toCSS.php:31

public function visitMixinDefinition($mixinNode){
    // mixin definitions do not get eval'd - this means they keep state
    // so we have to clear that state here so it isn't used if toCSS is called twice
    $mixinNode->frames = array();
    return array();
}

workaround:

A temporary workaround is to add a bogus CSS definition into mixin files like:

#bogus { display: none }    

possible solution:

Empty results of less-files should not be treated as an error. A warning would surely suffice. I can propose a PR if this is a valid solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: FrontendIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is not validGate 1 Failed. Automatic verification of issue format is failedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.1.xThe issue has been reproduced on latest 2.1 releaseReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releasebug reporttriage wanted

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions