I am trying to add module specific less file named _module.less inside my custom module Mynamespace_Mymodule in M2.

For that I have created module.xml file with below sequence.

<module name="Mynamespace_Mymodule" setup_version="0.0.1">
            <module name="Magento_Sales" />
            <module name="Magento_Payment" />
            <module name="Magento_Checkout" />

and thus corresponding sequence is generated inside app/etc/config.php file.

However the sequence for my _module.less file is not the same as the order of module I set from module.xml. Instead, my _module.less file comes before those two modules that I set inside sequence, so I have to use ugly !important flag every time inside less file to override css properties.

Here is how compiled order for _module.less is inside styles-m.less after grunt exec:theme command.

@import '../Mynamespace_Mymodule/css/source/_module.less';
@import '../Magento_Checkout/css/source/_module.less';
@import '../Magento_Sales/css/source/_module.less';

How magento decides order for _module.less file?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.