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?
Solved! Go to Solution.
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 !
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 !
Thanks, @Manthan Dave
This is working for me.
Hello @Shiwani Miglani
Happy to help and keep helping others