cancel
Showing results for 
Search instead for 
Did you mean: 

_module.less collection order in magento-2

_module.less collection order in magento-2

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">
        <sequence>
            <module name="Magento_Sales" />
            <module name="Magento_Payment" />
            <module name="Magento_Checkout" />
        </sequence>
</module>

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 of _module.less? How to override _module.less from other module in _module.less of our own module?

 

3 REPLIES 3

Re: _module.less collection order in magento-2

Hello @shashank_bhatt 

 

Have you run setup: upgrade after you change sequence?

 

if no then run and check it

 

 

if help you then mark as a solution.

 

 


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

Re: _module.less collection order in magento-2

@Sunil Patel 

Thanks for reply. I already ran upgrade command.

php bin/magento setup:upgrade

But still I am getting the same order.


Re: _module.less collection order in magento-2

Hello,

 

Did you find what the problem is? If yes could you please share? Thanks so much