❗ Note
Start the console from the administrator
- Install node.js to any location on your machine.
- Install Grunt CLI tool globally and locally. To do this, run the following command in a command prompt:
npm install -g grunt-cli
,npm install grunt --save-dev
- Install (or refresh) the
node.js
project dependency, including Grunt, for your Magento instance. To do this, run the following commands in a command prompt:
cd <your_Magento_instance_directory>
npm install
npm update
- Add your theme to Grunt configuration. To do this, in the
dev/tools/grunt/configs/themes.js
file, add your theme to module.exports like following:
module.exports = {
...
<theme>: {
area: 'frontend',
name: '<Vendor>/<theme>',
locale: '<language>',
files: [
'css/styles-m',
'css/styles-l'
],
dsl: 'less'
...
},
- (Optional) If you want to use Grunt for "watching" changes automatically, without reloading pages in a browser each time, install the LiveReload extension in your browser.
grunt clean:<theme>
– Removes the theme related static files in thepub/static
andvar
directories.grunt exec:<theme>
– Republishes symlinks to the source files to thepub/static/frontend/<Vendor>/<theme>/<locale>
directory.grunt less:<theme>
– Compiles.css
files using the symlinks published in thepub/static/frontend/<Vendor>/<theme>/<locale>
directorygrunt watch
– Tracks the changes in the source files, recompiles.css
files
Сomparison table Gulp vs Grunt
Gulp | Grunt | |
---|---|---|
Compilation of all themes (10 files): | 16sec | 33sec |
Custom theme compilation (2 files) | 4.5s | 11.2s |
- Download as a zip file or clone this.
- Copy
gulpfile.js
andpackage.json
in to the root directory - Install gulp globaly and locally using
npm install -g gulp-cli
,npm install gulp --save-dev
- Install modules: run a command in a root directory of your project
npm install
. - Compilation:
gulp less --<theme> --live (with live reload)
- Watcher:
gulp watch --<theme> --live (with live reload)
- For using liveReload install extension for your browser
❗ Note
Don't remove grunt modules (You must use
grunt exec:<theme>
command for republishes symlinks to the source files)