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?
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.
@Sunil Patel
Thanks for reply. I already ran upgrade command.
php bin/magento setup:upgrade
But still I am getting the same order.
Hello,
Did you find what the problem is? If yes could you please share? Thanks so much