{"id":346171,"date":"2022-07-29T08:19:30","date_gmt":"2022-07-29T08:19:30","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=346171"},"modified":"2024-11-12T05:34:24","modified_gmt":"2024-11-12T05:34:24","slug":"understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2\/","title":{"rendered":"Understanding Magento Theme: Use grunt js for better development in Magento 2"},"content":{"rendered":"\n<p>Hello friends! Today, we&#8217;ll go over how to use Magento built-in Grunt commands and learn how to add custom configurations to make development faster. <\/p>\n\n\n\n<p>This guide is especially useful if you&#8217;re working with a <a href=\"https:\/\/webkul.com\/magento-development\/\" target=\"_blank\" rel=\"noreferrer noopener\">Magento development company<\/a>, as it can help streamline and speed up your development process.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"overview\">Overview<\/h2>\n\n\n\n<p>You can use Grunt to automate any tasks you need, but out of the box Magento comes with pre-configured grunt tasks for compiling LESS files.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"prerequisites\">Prerequisites<\/h2>\n\n\n\n<p>There are only two major requirements. First of all,\u00a0you have to\u00a0<a href=\"https:\/\/devdocs.magento.com\/guides\/v2.3\/config-guide\/cli\/config-cli-subcommands-mode.html\">set<\/a>\u00a0your Magento 2 to the developer or default\u00a0<a href=\"https:\/\/devdocs.magento.com\/guides\/v2.3\/config-guide\/bootstrap\/magento-modes.html\">mode<\/a>. <\/p>\n\n\n\n<p>Note that with the default mode, you set the Less compilation mode to Server-side Less compilation, which is required for our final goal.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"grunt_prereq\"><a href=\"https:\/\/devdocs.magento.com\/guides\/v2.4\/frontend-dev-guide\/tools\/using_grunt.html#grunt_prereq\"><\/a>Installing and configuring Grunt<\/h2>\n\n\n\n<p>Magento has built-in Grunt tasks configured, but there are still several steps you need to take to be able to use it:<\/p>\n\n\n\n<p>Install&nbsp;<a href=\"https:\/\/nodejs.org\/en\/download\/package-manager\/\">node.js<\/a>&nbsp;to any location on your machine.<\/p>\n\n\n\n<p>Install Grunt CLI tool globally. To do this, run the following command in a command prompt<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">npm install -g grunt-cli<\/pre>\n\n\n\n<p>If you get an error that permission is denied, you&#8217;ll need to run the command as&nbsp;<code>sudo<\/code>&nbsp;or on Windows, you&#8217;ll need to run PowerShell or Command Prompt as an administrator.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"734\" height=\"291\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/rahul.png\" alt=\"rahul\" class=\"wp-image-346174\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/rahul.png 734w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/rahul-300x119.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/rahul-250x99.png 250w\" sizes=\"(max-width: 734px) 100vw, 734px\" loading=\"lazy\" \/><figcaption class=\"wp-element-caption\">Installation of grunt-cli<\/figcaption><\/figure>\n\n\n\n<p>Go to the&nbsp;<code>&lt;Magento_root&gt;<\/code>&nbsp;directory, copy and paste the contents of the following files:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><code>package.json.sample<\/code>\u00a0into\u00a0<code>package.json<\/code><\/li>\n\n\n\n<li><code>Gruntfile.js.sample<\/code>\u00a0into\u00a0<code>Gruntfile.js<\/code><\/li>\n\n\n\n<li><code>grunt-config.json.sample<\/code>\u00a0into\u00a0<code>grunt-config.json<\/code><\/li>\n<\/ol>\n\n\n\n<p>Install (or refresh) the&nbsp;<code>node.js<\/code>&nbsp;project dependency, including Grunt, for your Magento instance. To do this, run the following commands in a command prompt:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">cd your_Magento_instance_directory<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\">npm install<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\">npm update<\/pre>\n\n\n\n<p>There is also an optional step related to Grunt for \u201cwatching\u201d changes automatically, without reloading pages in a browser each time. <\/p>\n\n\n\n<p>To implement this feature, you have to install the\u00a0<a href=\"http:\/\/livereload.com\/extensions\/\">LiveReload extension<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"add_theme\">Adding themes to Grunt configuration<\/h2>\n\n\n\n<p>Add your Custom Theme to Grunt Configuration open this file, in the&nbsp;<code>dev\/tools\/grunt\/configs\/themes.js<\/code> and add your theme to&nbsp;<em>module.exports<\/em>&nbsp;like shown below:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">module.exports = {\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;theme&gt;: {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;area: &#039;&lt;area&gt;&#039;,\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name: &#039;&lt;Vendor&gt;\/&lt;theme&gt;&#039;,\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;locale: &#039;&lt;language&gt;&#039;,\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;files: &#091;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#039;&lt;path_to_file1&gt;&#039;, \/\/path to root source file\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#039;&lt;path_to_file2&gt;&#039;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;],\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dsl: &#039;less&#039;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},<\/pre>\n\n\n\n<p>Where the following notation is used:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>&lt;area><\/code>:-<\/strong> area code, can be either\u00a0<code>frontend<\/code>\u00a0or\u00a0<code>adminhtml<\/code>.<\/li>\n\n\n\n<li><strong>&lt;vendor_name>:-<\/strong>\u00a0Your vendor name.<\/li>\n\n\n\n<li><strong>&lt;theme_name>:-<\/strong>\u00a0Your theme code that corresponds to the theme directory name.<\/li>\n\n\n\n<li><strong>&lt;language>:-<\/strong>\u00a0language specified in the\u00a0<code>code_subtag<\/code>\u00a0format, for example\u00a0<code><strong>en_US<\/strong><\/code>. Only one locale can be specified here. To debug the theme with another locale, create one more theme declaration, having specified another value for\u00a0<code>language<\/code>.<\/li>\n\n\n\n<li><strong>&lt;path_to_file >:-<\/strong>\u00a0The path to the root source file, relative to the directory app\/design\/frontend\/&lt;Vendor>\/&lt;theme\/>\/web.<\/li>\n<\/ul>\n\n\n\n<p><strong>NOTE<\/strong>: If grunt gives the error \u201cError: Cannot find module \u2026.\u201d, check the path in your&nbsp;<code>grunt-config.json<\/code>&nbsp;file and correct as necessary.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Grunt commands<\/h2>\n\n\n\n<p>You just need to execute commands :<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>grunt clean<\/strong>\u00a0<strong>:-<\/strong>\u00a0Remove the theme-related static files in the pub\/static\/frontend\/ and var\/ directories.<\/li>\n\n\n\n<li><strong>grunt exec:-<\/strong>\u00a0To generate symlinks to the source files to pub\/static\/frontend\/<\/li>\n\n\n\n<li><strong>grunt less:-<\/strong>\u00a0Compile CSS files using symlinks published in pub\/static\/frontend\/<\/li>\n\n\n\n<li><strong>grunt watch:-<\/strong>\u00a0To track changes in source files, recompile .css files, and reload pages in a browser.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Grunt commands for s<strong>pecific theme<\/strong><\/h2>\n\n\n\n<p><strong>&nbsp; If you are using for a specific theme then execute commands :<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>grunt exec :<\/strong>\u00a0<strong>&lt;theme_name><\/strong>\u00a0:- To generate symlinks for a specific theme.<\/li>\n\n\n\n<li><strong>grunt less :<\/strong>\u00a0<strong>&lt;theme_name><\/strong>\u00a0:- To use symlinks published for a specific theme.<\/li>\n<\/ul>\n\n\n\n<p>After running&nbsp;<strong>\u201cgrunt watch\u201d<\/strong>&nbsp;will watch the&nbsp;<strong>*.less<\/strong>&nbsp;files and&nbsp;<strong>if some are changed, it will immediately rebuild the CSS file.<\/strong><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Custom Grunt configuration files<\/h2>\n\n\n\n<p>There are several ways to declare a custom configuration file.<\/p>\n\n\n\n<p><strong>How to declare a custom config file&nbsp;<\/strong><\/p>\n\n\n\n<p>There are two options that let you declare a custom config file in a different manner.<\/p>\n\n\n\n<p><strong>Option 1<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Copy the default configuration file to the preferred location in the Magento instance directory. Do not change the default file name.<\/li>\n\n\n\n<li>Open the\u00a0<code>grunt-config.json<\/code>\u00a0file in the Magento root and set configurations object as follows.\n<ul class=\"wp-block-list\">\n<li>key: file alias<\/li>\n\n\n\n<li>value: path to your custom file<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>If your custom configuration file\u00a0<code>local-themes.js<\/code>\u00a0is located in the\u00a0<code>&lt;magento_root>\/dev\/tools\/grunt\/configs<\/code>\u00a0directory, the following is already set in your\u00a0<code>grunt-config.json<\/code><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\">{ &quot;themes&quot;: &quot;dev\/tools\/grunt\/configs\/local-themes.js&quot; }<\/pre>\n\n\n\n<p>This path is also added to your .gitignore by default. If you are changing this name, It is also necessary to mention that this path is added to your .gitignore.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"how-to-declare-custom-configuration-file-option-2\">Option 2<\/h3>\n\n\n\n<p>You can also use the other way to declare a custom config file:<\/p>\n\n\n\n<p>In your Grunt related scripts, in the file router, set the alias and path to the custom configuration file. For example, to set the custom&nbsp;<code>themes.loc.js<\/code>&nbsp;configuration file, this would look like the following:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">filesRouter.set(&#039;themes&#039;, &#039;dev\/tools\/grunt\/configs\/themes.loc.js&#039;);<\/pre>\n\n\n\n<p>Note that It must be added earlier, than the&nbsp;<code>get()<\/code>&nbsp;method with this alias is called.<\/p>\n\n\n\n<p>In the&nbsp;<code>dev\/tools\/grunt\/configs\/<\/code>&nbsp;directory, create a copy of the default configuration file. Change its name by adding the \u201c.loc\u201d suffix. <\/p>\n\n\n\n<p>For example, your copy of&nbsp;<code>themes.js<\/code>&nbsp;will be&nbsp;<code>themes.loc.js<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"how-to-use-custom-configuration-file\">How to use a custom configuration file<\/h3>\n\n\n\n<p>Now you have to tell Grunt to use a custom configuration file, instead of the default one, add the following in your script:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Require file-router:<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\">var fileRouter = require(&#039;\/files-router&#039;);<\/pre>\n\n\n\n<p>2. Call the&nbsp;<code>get(%file_alias%)<\/code>&nbsp;method to get the configuration file.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">var themes = fileRouter.get(&#039;themes&#039;);<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Adding Custom Tasks<\/h2>\n\n\n\n<p>Now we&#8217;ll go over how to create custom tasks in Grunt that will help make our development faster.<\/p>\n\n\n\n<p>One use case we can automate is when we update a module&#8217;s version. Usually, you have to run 3 different tasks:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">php bin\/magento setup:upgrade\nphp bin\/magento setup:di:compile\nphp bin\/magento setup:static-content:deploy -f<\/pre>\n\n\n\n<p>Instead of running the above commands, we&#8217;ll create a new task called&nbsp;<code><strong>upgrade<\/strong><\/code>&nbsp;that will run all these tasks for us.<\/p>\n\n\n\n<p>To create a new task, we need to create a new file in&nbsp;<code>dev\/tools\/grunt\/tasks<\/code>. We&#8217;ll create a new file there called&nbsp;<strong><code>upgrade.js<\/code><\/strong><\/p>\n\n\n\n<p>The file should export a function that takes&nbsp;<code>grunt<\/code>&nbsp;as a parameter:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">module.exports = function(grunt) {\n\t\/\/Write code here for the custom task\n};<\/pre>\n\n\n\n<p>The reason behind this is that&nbsp;<code>Gruntfile.js<\/code>&nbsp;fetches all files in the&nbsp;<code>tasks<\/code>&nbsp;directory, and passes them the instance of&nbsp;<code>grunt<\/code>.<\/p>\n\n\n\n<p>Now, we&#8217;ll declare some functions that will be helpful for us:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">const exec = require(&#039;child_process&#039;).execSync,\n        log = grunt.log.write,\n        ok = grunt.log.ok<\/pre>\n\n\n\n<ol class=\"wp-block-list\">\n<li><code>exec<\/code>: It&#8217;s actually the function\u00a0execSync\u00a0that allows us to run commands we would run in the shell. We&#8217;ll use it to run the commands mentioned above.<\/li>\n\n\n\n<li><code>log<\/code>: A function that allows us to output information messages.<\/li>\n\n\n\n<li><code>ok<\/code>: A function that allows us to output successful messages.<\/li>\n<\/ol>\n\n\n\n<p>This time to register our task, we&#8217;ll use&nbsp;<code>grunt.registerTask<\/code>&nbsp;which takes two parameters: the name of the task and the function that the task will execute once called.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">grunt.registerTask(&#039;upgrade&#039;, function () {\n});<\/pre>\n\n\n\n<p>The first parameter is the command to run, and the second parameter is an options object.<\/p>\n\n\n\n<p>The option we&#8217;re passing is\u00a0<code><strong>stdio<\/strong><\/code>\u00a0with the value\u00a0<code><strong>inherit<\/strong><\/code>, which means that the output should be printed to the terminal we&#8217;re calling the task from.<\/p>\n\n\n\n<p>We run a grunt task with&nbsp;<code>grunt.task.run<\/code>&nbsp;passing it the name of the task. In the end, we&#8217;re just outputting a successful message to show that our task is done.<\/p>\n\n\n\n<p>Final code of&nbsp;<code>upgrade.js<\/code>&nbsp;should look like this:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">module.exports = function(grunt) {\n    const exec = require(&#039;child_process&#039;).execSync,\n        log = grunt.log.write,\n        ok = grunt.log.ok\n\n    grunt.registerTask(&#039;upgrade&#039;, function () {\n        log(&#039;Running setup:upgrade...&#039;)\n        exec(&#039;php bin\/magento setup:upgrade&#039;, {stdio: &#039;inherit&#039;})\n        log(&#039;Running setup:di:compile&#039;)\n        exec(&#039;php bin\/magento setup:di:compile&#039;, {stdio: &#039;inherit&#039;})\n        log(&#039;Running deploy...&#039;)\n        grunt.task.run(&#039;deploy&#039;)\n        ok(&#039;Upgrade finished!&#039;)\n    });\n}<\/pre>\n\n\n\n<p>Finally, test it out. In the terminal run:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">grunt upgrade<\/pre>\n\n\n\n<p>If everything is done correctly, &nbsp;the task will run all mentioned commands. This task will make it easier next time you need to upgrade because of a new or updated module! Now, you can automate any task with the same process.<\/p>\n\n\n\n<p>Happy Coding! \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello friends! Today, we&#8217;ll go over how to use Magento built-in Grunt commands and learn how to add custom configurations to make development faster. This guide is especially useful if you&#8217;re working with a Magento development company, as it can help streamline and speed up your development process. Overview You can use Grunt to automate <a href=\"https:\/\/webkul.com\/blog\/understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":377,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9121],"tags":[12961,12960,2070],"class_list":["post-346171","post","type-post","status-publish","format-standard","hentry","category-magento-2","tag-custom-task-using-gruntjs","tag-gruntjs","tag-magento2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Use grunt js for better development in Magento 2<\/title>\n<meta name=\"description\" content=\"We\u2019ll go over how to use Magento out-of-the-box commands in Grunt, and how to add our own to make our development faster.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Use grunt js for better development in Magento 2\" \/>\n<meta property=\"og:description\" content=\"We\u2019ll go over how to use Magento out-of-the-box commands in Grunt, and how to add our own to make our development faster.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-07-29T08:19:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-12T05:34:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2022\/07\/rahul.png\" \/>\n<meta name=\"author\" content=\"Rahul Chaudhary\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rahul Chaudhary\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2\/\"},\"author\":{\"name\":\"Rahul Chaudhary\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/07d5b40e4a4b5c6996d171e134826b75\"},\"headline\":\"Understanding Magento Theme: Use grunt js for better development in Magento 2\",\"datePublished\":\"2022-07-29T08:19:30+00:00\",\"dateModified\":\"2024-11-12T05:34:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2\/\"},\"wordCount\":1181,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2022\/07\/rahul.png\",\"keywords\":[\"custom task using gruntjs\",\"gruntjs\",\"Magento2\"],\"articleSection\":[\"Magento 2\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2\/\",\"url\":\"https:\/\/webkul.com\/blog\/understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2\/\",\"name\":\"Use grunt js for better development in Magento 2\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2022\/07\/rahul.png\",\"datePublished\":\"2022-07-29T08:19:30+00:00\",\"dateModified\":\"2024-11-12T05:34:24+00:00\",\"description\":\"We\u2019ll go over how to use Magento out-of-the-box commands in Grunt, and how to add our own to make our development faster.\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/rahul.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/rahul.png\",\"width\":734,\"height\":291,\"caption\":\"rahul\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Understanding Magento Theme: Use grunt js for better development in Magento 2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/07d5b40e4a4b5c6996d171e134826b75\",\"name\":\"Rahul Chaudhary\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/40e957d926aaa241dc1de7dd09cfea4a0c86ed9fa29bb7eda51de1a8967864e7?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/40e957d926aaa241dc1de7dd09cfea4a0c86ed9fa29bb7eda51de1a8967864e7?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Rahul Chaudhary\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/rahulchaudhary766\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Use grunt js for better development in Magento 2","description":"We\u2019ll go over how to use Magento out-of-the-box commands in Grunt, and how to add our own to make our development faster.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2\/","og_locale":"en_US","og_type":"article","og_title":"Use grunt js for better development in Magento 2","og_description":"We\u2019ll go over how to use Magento out-of-the-box commands in Grunt, and how to add our own to make our development faster.","og_url":"https:\/\/webkul.com\/blog\/understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2022-07-29T08:19:30+00:00","article_modified_time":"2024-11-12T05:34:24+00:00","og_image":[{"url":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2022\/07\/rahul.png","type":"","width":"","height":""}],"author":"Rahul Chaudhary","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Rahul Chaudhary","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2\/"},"author":{"name":"Rahul Chaudhary","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/07d5b40e4a4b5c6996d171e134826b75"},"headline":"Understanding Magento Theme: Use grunt js for better development in Magento 2","datePublished":"2022-07-29T08:19:30+00:00","dateModified":"2024-11-12T05:34:24+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2\/"},"wordCount":1181,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2022\/07\/rahul.png","keywords":["custom task using gruntjs","gruntjs","Magento2"],"articleSection":["Magento 2"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2\/","url":"https:\/\/webkul.com\/blog\/understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2\/","name":"Use grunt js for better development in Magento 2","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2022\/07\/rahul.png","datePublished":"2022-07-29T08:19:30+00:00","dateModified":"2024-11-12T05:34:24+00:00","description":"We\u2019ll go over how to use Magento out-of-the-box commands in Grunt, and how to add our own to make our development faster.","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/rahul.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/rahul.png","width":734,"height":291,"caption":"rahul"},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/understanding-magento-theme-use-grunt-js-for-better-development-in-magento-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Understanding Magento Theme: Use grunt js for better development in Magento 2"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/07d5b40e4a4b5c6996d171e134826b75","name":"Rahul Chaudhary","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/40e957d926aaa241dc1de7dd09cfea4a0c86ed9fa29bb7eda51de1a8967864e7?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/40e957d926aaa241dc1de7dd09cfea4a0c86ed9fa29bb7eda51de1a8967864e7?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Rahul Chaudhary"},"url":"https:\/\/webkul.com\/blog\/author\/rahulchaudhary766\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/346171","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/377"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=346171"}],"version-history":[{"count":4,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/346171\/revisions"}],"predecessor-version":[{"id":473542,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/346171\/revisions\/473542"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=346171"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=346171"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=346171"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}