Magento – (Magento2) Grunt Less problem with a new theme

gruntlessmagento2.2

I've cloned the blank theme for app/design/frontend/lima/mdl, swapping Magento/blank for lima/mdl and give this error:

Processed Area: frontend, Locale: pt_BR, Theme: lima/mdl, File
type: less.

[InvalidArgumentException]
Verify entered values of the argument and options. Unable to resolve the source file for
'frontend/lima/mdl/pt_BR/css/styles-m.less'

my files:

app/design/frontend/lima/mdl/registration.php

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::THEME,
    'frontend/lima/mdl',
    __DIR__
);

app/design/frontend/lima/mdl/theme.xml

<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
    <title>Lima MDL</title>
    <media>
        <preview_image>media/preview.jpg</preview_image>
    </media>
</theme>

app/design/frontend/lima/mdl/composer.json

{
    "name": "lima/mdl",
    "description": "N/A",
    "require": {
        "php": "7.0.2|7.0.4|~7.0.6|~7.1.0",
        "magento/framework": "101.0.*"
    },
    "type": "magento2-theme",
    "version": "100.2.1",
    "license": [
        "OSL-3.0",
        "AFL-3.0"
    ],
    "autoload": {
        "files": [
            "registration.php"
        ]
    }
}

dev/tools/grunt/configs/themes.js

module.exports = {
    blank: {
        area: 'frontend',
        name: 'Magento/blank',
        locale: 'pt_BR',
        files: [
            'css/styles-m',
            'css/styles-l',
            'css/email',
            'css/email-inline'
        ],
        dsl: 'less'
    },
    luma: {
        area: 'frontend',
        name: 'Magento/luma',
        locale: 'pt_BR',
        files: [
            'css/styles-m',
            'css/styles-l'
        ],
        dsl: 'less'
    },
    mdl: {
        area: 'frontend',
        name: 'lima/mdl',
        locale: 'pt_BR',
        files: [
            'css/styles-m',
            'css/styles-l'
        ],
        dsl: 'less'
    },
    backend: {
        area: 'adminhtml',
        name: 'Magento/backend',
        locale: 'pt_BR',
        files: [
            'css/styles-old',
            'css/styles'
        ],
        dsl: 'less'
    }
};

I am running:

grunt clean; grunt exec; grunt less:mdl; sudo chmod 777 -R var/*;

I solved fixing permissions in all project, but I still don't know why…

Best Answer

You need to make sure that you run the commands from your Magento installation directory.

grunt clean: mdl
grunt exec: mdl
grunt less: mdl
chmod 0777 -R var/*
chmod 0777 -R pub/static/* 
chmod 0777 -R generated/* 
Grunt watch

To check more on how to integrate less on Magento 2. Please read our blog here.

Hope this will help you..!

Related Topic