Magento – Extending/Overriding base JavaScript in Magento 2

frontendjavascriptmagento2

AFAIK, the mage.confirm widget is defined in this file:

vendor/magento/module-ui/view/base/web/js/modal/confirm.js

I'm looking to override the file in my theme to provide alternative default behaviour for confirm modals (e.g. the one displayed in M2 when removing an item from the minicart).

I've tried to customise the widget following the steps in the FE dev docs without success. Is it possible to override this base file?

Best Answer

You could locate this file in you theme. As your original file is in:

vendor/magento/module-ui/view/base/web/js/modal/confirm.js

Then create a folder:

app/design/[vendor]/[theme]/Magento_Ui/web/js/modal/confirm.js

This file will be catched during static-content deployment