Magento comes with pre-configured grunt tasks for compiling fewer files. Make sure that you set your Magento application to the developer or default mode. We have to follow the below steps to install and configure.
Install nodeJS
To do this, run the following command in a command prompt:
Install Grunt CLI globally
To do this, run the following command in a command prompt:
Create the files
Move to your Magento_root directory and type the following commands
Install (or refresh) the node.js project dependency
Grunt configuration file
Copy the contents of themes.js into local-themes.js in the dev/tools/grunt/configs/ directory.
{
"themes": "dev/tools/grunt/configs/local-themes"
}
Configure your theme
Go to dev/tools/grunt/configs/local-themes.js. Under module.exports, paste the following json code to configure a theme. Replace the necessary lines.
theme: {
area: 'frontend',
name: 'Vendor/theme',
locale: 'en_US',
files: [
'css/styles-m',
'css/styles-l'
],
dsl: 'less'
}
Example:
default: {
area: 'frontend',
name: OX/default',
locale: 'en_US',
files: [
'css/styles-m',
'css/styles-l'
],
dsl: 'less'
},
In Last, You just need to execute commands:
grunt exec:theme - To generate symlinks for a specific theme (grunt exec:default).
grunt less:theme - To use symlinks published for a specific theme.
grunt watch:theme - To track changes in source files, recompile .css files, and reload pages in a browser.
That’s it! Things should now be a bit more clear on how to install and configure Grunt in Magento2.
Contact Details:
Address: No. 15, Ground Floor, A Block, Devapragasam Trade Centre, Poonamalle High Road, Maduravoyal, Chennai - 600 095, Tamilnadu, India.
Mobile Number: +918056293534
For more Information: https://www.oxsoftwares.com