Magento 2 – How to Override a HTML File Using a Custom Module

htmlmagento2overridestemplate

I'm developing a custom module for payment method in Magento 2. Currently, I'm using cc-form.html from vendor directory and module working fine. See below path:

vendor/magento/module-payment/view/frontend/web/template/payment/cc-form.html

Is there any way to override HTML file?

Note: I would like to override it using a custom extension.
See below path:

app/code/Namespace/Module/view/frontend/web/template/payment/cc-form.html

Any help would be appreciated. Thank you!

Best Answer

Working solution.

Just create or edit requirejs-config.js file from below path.

/app/code/Namespace/Module/view/frontend/requirejs-config.js

And place below code in requirejs-config.js

var config = {
    map: {
        '*': {
          'Magento_Payment/template/payment/cc-form.html': 
              'Namespace_Module/template/payment/cc-form.html'
        }
  }
};

So we can override any html file in this way.

Related Topic