How to override js in magento 2

 How to override js in magento 2

To override js we need requirejs-config.js

requirejs-config.js need to create at [Vendor]/[Module]/view/frontend/requirejs-config.js

var config = {
    map: {
        '*': {
            'Magento_Checkout/js/model/shipping-rates-validator':'Vendor_Module/js/model/shipping-rates-validator'
        }
    }
};

Create file at app/code/Vendor/Module/view/frontend/web/js/model/shipping-rates-validator.js

Write your inside file and boom!!! 

If developer mode is on and symlinks are generating clear cache bin/magento cache:clean

If production mode is on , need to deploy static content files using command bin/magento s:s:d 


If like efforts, Please share, comment and subscribe for future posts and inspire more.

Comments

Popular posts from this blog

Hosting and Goodies

Magento 2 Import Scripts

How to add product attribute value in minicart magento 2