0

I have a custom html template where I have classes.

On layout I have added my css like this:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <css src="css/application.css" />
    </head>
    <body> 
        <referenceContainer name="content">
            <block class="Vendor\Application\Block\Main" name="application_send" template="Vendor_Application::application.phtml"/>
        </referenceContainer>    
    </body>
</page>

And inside PHTML i'm using a javascript component in order to render html template

Just like this:

 <div id="port-form" data-bind="scope:'port-form'">
      <!-- ko template: getTemplate() --><!-- /ko -->
      <!-- ko template: template2--><!-- /ko -->
      <!-- ko template: template3 --><!-- /ko -->
        <script type="text/x-magento-init">
        {
            "#port-form": {
                "Magento_Ui/js/core/app": {
                  "components": {
                        "port-form": {
                            "component": "Vendor_Application/js/port-app-form",
                            "quote_data": <?= /* @escapeNotVerified */ $data ?>,
                            "quantities": <?= /* @escapeNotVerified */ $quantities ?>
                        }
                    }
                }
            }
        }
        </script>

It's not taking any effect

I get this error:

Refused to apply style from '.../en_US/css/application.css' because its MIME type ('text/plain') is not a supported stylesheet MIME type, and strict MIME checking is enabled

Greetings

9
  • Where exactly is your CSS file placed? May 26 at 22:20
  • You can change : <css src="css/application.css" /> to <css src="Vendor_Application::css/application.css" />
    – nhungo duc
    May 27 at 1:52
  • @MichałBiarda my css is under web/css/application.css May 27 at 2:18
  • @nhungoduc it did not work May 27 at 2:21
  • have you cleared magento cache if so maybe your css part is wrong or maybe your browser cache
    – nhungo duc
    May 27 at 3:13
0

please add css under app/code/Vendor/Module/view/web/css and add in xml like

 <css src="Vendor_Module::css/application.css" />
2
  • I'm not using a theme, I'm using it into a module May 27 at 14:25
  • Answer updated. May 27 at 14:55

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.