Sometimes you want to modify the Magento JS core. But you can’t modify directly in Magento source code. So you should override Magento JS. The following steps will show you how to override Magento Js core in Magento 2.
Get build your Magento marketplace store with no-time, consult today!!!
How to Override Magento JS core in Magento 2?
Step 1:
Create Requires configuration file requires.config.js
var config = { "map": { "*": { "<default_component>": "<custom_component>" } } };
The following notations are:
- Default component
- Custom component
For example: if you want to use a custom component instead of a default component like requires.config.js should contain the following steps:
var config = { "map": { "*": { "menu": "/js/navigation-menu", "mage/backend/menu": "js/navigation-menu", } } };
Step 2:
Set your needs.config.js in one in all the subsequent directories:
Theme file:<Theme_dir>
Module file: <module_dir>/view/frontend</code>
The above-mentioned two steps are the shortest process for you to manage how to override Magento JS core in Magento 2 easily. Every store in Magento has several elements.
Build your Magento 2 store with an on-demand platform, click here.
Leave a Reply