cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2.3: I need to create Requirejs file for custom theme.

SOLVED

Magento 2.3: I need to create Requirejs file for custom theme.

I have installed a new Magento setup on the local server. I have created a custom theme for my site and I need to create a requirejs file for the custom theme.

Please suggest. How I can create and add this file in the custom theme?

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Magento 2.3: I need to create Requirejs file for custom theme.

Hello @Shiwani Miglani 

 

You can add require-js file on theme level at below location : 

 

app/design/frontend/<Vendor>/<theme>/requirejs-config.js

Then in the requirejs-config.js file - you will require to call your custom js file like below : 

 

var config = {
  "map": {
    "*": {
      "menu": "js/navigation-menu"
    }
  }
};

Put your cusotm js file into the web/js directory - then call it like above !

 

your requirejs-config.js will call  your custom js file !

 

Fore more details refer this link - https://devdocs.magento.com/guides/v2.3/javascript-dev-guide/javascript/custom_js.html

 

Hope it helps !

 

if issue solved,Click Kudos & Accept as Solution

View solution in original post

3 REPLIES 3

Re: Magento 2.3: I need to create Requirejs file for custom theme.

Hello @Shiwani Miglani 

 

You can add require-js file on theme level at below location : 

 

app/design/frontend/<Vendor>/<theme>/requirejs-config.js

Then in the requirejs-config.js file - you will require to call your custom js file like below : 

 

var config = {
  "map": {
    "*": {
      "menu": "js/navigation-menu"
    }
  }
};

Put your cusotm js file into the web/js directory - then call it like above !

 

your requirejs-config.js will call  your custom js file !

 

Fore more details refer this link - https://devdocs.magento.com/guides/v2.3/javascript-dev-guide/javascript/custom_js.html

 

Hope it helps !

 

if issue solved,Click Kudos & Accept as Solution

Re: Magento 2.3: I need to create Requirejs file for custom theme.

Thanks, @Manthan Dave 

This is working for me.

Re: Magento 2.3: I need to create Requirejs file for custom theme.

Hello @Shiwani Miglani 

 

Happy to help and keep helping others Smiley Happy

if issue solved,Click Kudos & Accept as Solution