Skip to content

How to remove Default style-m.css and styles-l.css Stylesheet, Add Back One Page Only

I have a Magento 2 client with a strange theme that is using scss and to make a long story short I need to remove the styles-l and styles-m css/styles from vendor/magento/theme-frontend-blank/Magento_Theme/layout/default_head_blocks.xml

like this:

<remove src="css/styles-m.css"/>
<remove src="css/styles-l.css"/>

That works fine but then add them back on checkout only (so the one page checkout styles work) like this using checkout_index_index.xml:

<head>
      <css src="css/styles-m-checkout.css"/>
      <css src="css/styles-l-checkout.css"/>
</head>

This does not work, it seems once a stylesheet is removed it can’t be added back. Any ideas on how to handle this situation?

I thought about manually copying those 2 css files to a new location and re-adding them but since they are auto-generated I’d like to avoid this method.