I created a custom module that overrides the addtocart.phtml file. In that module, I also created a css file. Here is what I did:
Here is my layout - catalog_product_view.xml
:
<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="Vendor_Module::css/style.css"/>
</head>
<body>
<referenceBlock name="product.info.addtocart">
<action method="setTemplate">
<argument class="Magento\Catalog\Block\Product\View" name="template" xsi:type="string">Vendor_Module::product/view/addtocart.phtml</argument>
</action>
</referenceBlock>
<referenceBlock name="product.info.addtocart.additional">
<action method="setTemplate">
<argument class="Magento\Catalog\Block\Product\View" name="template" xsi:type="string">Vendor_Module::product/view/addtocart.phtml</argument>
</action>
</referenceBlock>
</body>
</page>
and then I put the style.css
in /Vendor/Module/view/frontend/web/css
I thought that in this case the css file could be visible ONLY in the module, but it is not. How can I make it visible ONLY in that phtml file? I mean, I want the css to be able to edit ONLY the files into the module.
Is it possible?
Thanks