0

I want to override Magento's Magento_Checkout/js/view/billing-address.js with my custom JS file, for that I have added below code in my requirejs-config.js

var config = {
 map: {
 "*": {
 "Magento_Checkout/js/view/billing-address": "Example_Module/js/view/billing-address"
 }
 }
};

This works perfectly and I can see my js file overriding magento's default file.

The issue is when I enable JS minify option from admin panel, my JS file does not get loaded and checkout page displays below error.

Failed to load the Magento_Checkout/js/view/billing-address component.

Is there anyway to resolve this issue?

asked Jun 8, 2018 at 10:05
2
  • I hope my solution will work for you! Commented Jun 8, 2018 at 10:13
  • Try with the different name like this : var config = { map: { "*": { "Magento_Checkout/js/view/billing-address": "Example_Module/js/view/custom-billing-address" } } }; Commented Jun 8, 2018 at 10:15

1 Answer 1

2

Solution:

In your modules config.xml file add the following:

Example/Module/etc/config.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
 <default>
 <dev>
 <js>
 <minify_exclude>
 Example_Module/js/view/billing-address.js
 </minify_exclude>
 </js>
 </dev>
 </default>
</config>

rm -rf pub/static/frontend/

php bin/magento setup:static-content:deploy

After doing above steps it is working for me.

answered Jun 8, 2018 at 10:12
5
  • Hi, I have tried above code but the issue is the same. I have tried with Magento_Checkout/js/view/billing-address.js and Example_Module/js/view/billing-address.js for above code but none worked. Commented Jun 8, 2018 at 11:11
  • @JaiminSutariya, I have updated my answer and its working for me. I have tested it in my local. Commented Jun 8, 2018 at 11:39
  • Thanks Nikunj. I got to override default billing-address.js with my JS but the error is not resolved. There is still the error Failed to load the Magento_Checkout/js/view/billing-address component. and the checkout page keeps loading. Commented Jun 8, 2018 at 12:09
  • What above code perform an action? it will exclude billing-address.js to minify? Commented Jul 26, 2019 at 11:16
  • Because I am facing the relevant issue while checkout it will redirect to 404 because i have override this js in my custom module using require.js. if i use your answer code then it is working fine. i just want to know what is the reason? Commented Jul 26, 2019 at 11:20

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.