How to use grunt in Magento 2?

Step 1: Install Node.js

Step 2: Install Grunt CLI

npm install -g grunt-cli

Step 3: Install Node.js dependencies

cd <your_Magento_instance_directory> npm install npm update

Step 4: Add a theme to Grunt configuration

module.exports = {
...
<theme>: {
area: 'frontend',
name: '<Vendor>/<theme>',
locale: '<language>',
files: [
'<path_to_file1>', //path to root source file
'<path_to_file2>'
],
dsl: 'less'
...
},
}

Step 5: Run Grunt commands

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store