How to include less file in xml file in Magento2? - less

How to include 'less' file in the particular XML file. I want it to import 'less' file for only on the catalog page. So I tried by creating CSS file and inside the CSS file imported the 'less' file. Then, in XML I have added a CSS file. But it's not worked. How to add 'less' file only for the catalog page or how to include in the particular XML file.

Maybe start to read about pre-processing files works?
https://devdocs.magento.com/guides/v2.4/frontend-dev-guide/css-topics/css-preprocess.html
If you want to import a new .less file in your theme, you have to create an _extend.less file in your Magento_Catalog theme module.
And in your _extend.less add the following CSS rule :
#import "path/to/your/file.less";
And that's it.

Related

Unable to load local files using import/require

I can't load local files (jpg, png, json...) with either
import img from '../../../../assets/images/myImage.png';
require('../../../../assets/images/myImage.png');
With import VS Code notifies me that the module is not found. I can't see files in folders. What am I doing wrong?
At first you would check if file path is correct.
If file path is correct you load it simply.
(../../../../ is bad statement for files loading.)
The step is below
Please define package.json file into assets folder.
The content of package.json file looks like this
{
"name" : "#assets"
}
then you can load the file which is in assets folder like this
const img = require('#assets/images/myImage.png');

I cannot install PhpWord Yii

I have tried to install PhpWord to yii. I have downloaded zip file and extracted it into extentions folder:
extenstions
--PHPWord
--PHPWord.php
However, I cannot make it to run. I got following error:
include(PHPWord.php): failed to open stream: No such file or directory
How can i solve it?
After extracting the file in extension folder, you have to import that file in controller.
Yii::import('ext.phpword.PHPWord');
First of all, you didn't say if it's Yii 1 or 2. They have different autoloading methods.
Second, you have extracted it into extension folder, and I assume your file where you want to include it is in a completely different folder.
You should do it like this
include('/full/path/to/PHPWord.php');
You need either absolute or a relative path to the file (I suggest using abosulte path (the one I used as an example).
Relative path means the path to the file you want to include compared to where your file, in which you are including it, is.

How to edit css : Bigcommerce Stencil

How can I edit in CSS.
In Stencil framework can't found .css file.
In assets folder only found .scss file.
I want to edit in theme.css
How can I edit ?
Can any body help me ?
If you are developing a stencil theme locally and have ran stencil start it watches your SCSS files. So one option is you could add any custom CSS you want to the /assets/scss/theme.scss file.
Another option is you could create your own SCSS file, say for example custom.scss, and place it in /assets/scss/. Then import it to your theme.scss like this #import "custom" . Make sure you place it at the bottom of your theme.scss file so it overrides any css you are wishing to alter.
the .scss files are the css files. The stencil framework uses scss instead of the regular css.
This link should help guide you on how to edit the files: https://support.bigcommerce.com/articles/Public/Using-the-Stencil-Theme-Editor
the .scss files are the css files. The stencil framework uses scss instead of the regular css.
Please check this path /assets/scss/theme.scss

How to include the dijit.css and other related .css files in the dojo build file

I'm trying to create a dojo build file. What do I need to add in the profile.js file to include all the .css files inside the dojo build.js file. I'm getting dijit.js and other .js files, but the dependent .css files are not getting built into the build.js file
I'm using dojo 1.8
It doesn't really make sense to ask to combine JS and CSS into a single file. JavaScript is JavaScript; CSS is CSS.
That said, you should be able to get down to as little as one CSS request by specifying cssOptimize: 'comments' in your build profile, which will strip comments from CSS files within packages the build processes, and flatten imports. As a result, each Dijit theme's main CSS file (e.g. themes/claro/claro.css) will then require only one request, rather than requests for each component.

ActiveAdmin: changing css file?

I'm confused on where to put my new css file for ActiveAdmin to use. I have a folder called public/admin/active_admin.css and here https://github.com/gregbell/active_admin/issues/261, it says to put it in active_admin.rb but this doesn't exist in my application. Where does it go?
All you need to add is
# active_admin.rb
config.register_stylesheet 'active_admin_custom.css'
in the file config/application.rb (or an environment-specific config file) then the file /public/stylesheets/active_admin_custom.css
or you can create a new file:
config/initializers/active_admin.rb and put that line of code in there.