You can add CSS file as following way for your custom module.
Open you layout file e.g.
to add custom module JS file you can use standard way as mentioned with below link.
How to load custom module js file in magento 2?
Optional suggestion (Optional)
You can use the standard way of Magento 2 to call
You can call JS using
You may call
So It will call automatically as well as
Open you layout file e.g.
modulename_index_view.xml
and following code in <head> section.
1: <head>
2: <css src="Test_New::css/my.css"/>
3: </head>
to add custom module JS file you can use standard way as mentioned with below link.
How to load custom module js file in magento 2?
Optional suggestion (Optional)
You can use the standard way of Magento 2 to call
css
and js
rather than
Call CSS
and JS
files directly into layout
file.You can call JS using
requirejs
module. (You can maintain dependency of code.)You may call
css
file using _module.less
just put it under app\code\<Vendor>\<ModuleName>\view\frontend\web\css\source
.So It will call automatically as well as
_module.less
will compile by grunt tool
and converted into your theme or module css
No comments:
Post a Comment