Magento 2 – How to Replace a Core JavaScript

javascriptmagento2swatches

I was trying to replace magento 2 core javascript file for Swatches render which is located at app/code/Magento/Swatches/view/frontend/web/js/SwatchRenderer.js . And I followed official guide for this – http://devdocs.magento.com/guides/v2.0/javascript-dev-guide/javascript/custom_js.html , but it did not work.

I have uploaded my module on GIT. Can someone check and tell me what is the issue ? Here is the GIT Link for the module created – https://github.com/chamalC/magento-2-replace-javascript/tree/master/app/code/Muaw/CustomSwatches

Best Answer

Try below code in your requirejs-config.js

 var config = {
     map: {
    '*': {
        swatchRenderer: 'Muaw_CustomSwatches/js/SwatchRenderer'
    }
}};
Related Topic