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:


Is there any way to override HTML file?

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


Any help would be appreciated. Thank you!

  • when did you use this form, please show link or map site.
    – MrTo-Kane
    Commented May 25, 2016 at 8:30

4 Answers 4


Working solution.

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


And place below code in requirejs-config.js

var config = {
    map: {
        '*': {

So we can override any html file in this way.

  • doesn't work for email template html file in module sales?
    – fudu
    Commented Oct 2, 2018 at 4:04
  • are we just creating registration.php,module.xml and composer.json then requirejs-config.js and the html? Commented Apr 20, 2020 at 13:57

You can just add your cc-form.html file inside your theme payment module.


You can change according to your requirements at above place.

Remove var folder from root and remove pub/static/frontend folder.

You must have run command php bin/magento setup:static-content:deploy

Clear your browser cache and check.

  • I know it will work fine if i place cc-form.html under my theme. but i am creating extension so i can't place it under theme. i must have to put this file under module's directory. Commented May 25, 2016 at 11:40
  • 1
    Thank you rakesh. i found the solution at stackoverflow.com/questions/37430036/… Commented May 27, 2016 at 7:19

Accepted solution is right, but I copy here the full @AntonGuz answer from the "Stack Overflow" (very well explained):

Yes, there is. You can look in pub static to see how path to static asset constructed.

How it works

Every asset is accessible from the page by itenter code heres "RequireJS ID". It similar to real path, but varied.

For example file http://magento.vg/static/adminhtml/Magento/backend/en_US/Magento_Theme/favicon.ico.

It's real path is /app/code/Magento/Theme/view/adminhtml/web/favicon.ico. It's RequireJS ID is Magento_Theme/favicon.ico. This means that file could be accessible via require("text!Magento_Theme/favicon.ico") or similar command.

You can find that RequireJS ID consist with module name and useful part of path (after folder web).

How can I replace a file

So you have file

On the page it loaded with src as

So its RequireJS ID is

Side note: Inside UI components stuff it equals to Magento_Payment/payment/cc-form. Words "template" and ".html" are added automatically.

And now you can replace this file for application via RequireJS config

var config = {
  "map": {
    "*": {

This code snippet you place in requirejs-config.js file in your module. That is all.

Perhaps it will help somebody to understand as it occurs.

  • How do you add and modify the JS file for this html Commented Jul 23, 2019 at 9:20

I don't know since which version of Magento2 it is required but if you want to override template from Magento_Ui module, you need to provide path like this:

var config = {
    map: {
        "*": {

Because in this file:


There is path mapping:

 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.

var config = {
    paths: {
        'ui/template': 'Magento_Ui/templates'
    map: {
        '*': {
            uiElement:      'Magento_Ui/js/lib/core/element/element',
            uiCollection:   'Magento_Ui/js/lib/core/collection',
            uiComponent:    'Magento_Ui/js/lib/core/collection',
            uiClass:        'Magento_Ui/js/lib/core/class',
            uiEvents:       'Magento_Ui/js/lib/core/events',
            uiRegistry:     'Magento_Ui/js/lib/registry/registry',
            consoleLogger:  'Magento_Ui/js/lib/logger/console-logger',
            uiLayout:       'Magento_Ui/js/core/renderer/layout',
            buttonAdapter:  'Magento_Ui/js/form/button-adapter'

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.