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? Commented May 26, 2021 at 22:20
  • You can change : <css src="css/application.css" /> to <css src="Vendor_Application::css/application.css" /> Commented May 27, 2021 at 1:52
  • @MichałBiarda my css is under web/css/application.css Commented May 27, 2021 at 2:18
  • @nhungoduc it did not work Commented May 27, 2021 at 2:21
  • have you cleared magento cache if so maybe your css part is wrong or maybe your browser cache Commented May 27, 2021 at 3:13

1 Answer 1

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 Commented May 27, 2021 at 14:25
  • Answer updated. Commented May 27, 2021 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.