0

How can I override this file on my theme?

/vendor/magento/module-ui/view/frontend/web/js/view/messages.js

I'm a newbie to M2

2

In your custom module [Namespace]/[Module]/view/frontend/requirejs-config.js add this

var config = {
    map: {
        '*': {
            'Magento_Ui/Magento_Ui/js/view/messages.js':'[Namespace]_[Module]/js/view/messages.js'
        }
    }
};

your overridden js file should be here [Namespace]_[Module]/view/frontend/web/js/view/messages.js

run below command:

php bin/magento setup:upgrade && php bin/magento setup:static-content:deploy -f

read more here: Extending / Overriding JS in Magento 2

  • I don't see the view folder on the theme but I saw theme-name/require-config.js. Is it the same file? – thedeadlyone Oct 29 '18 at 10:54
  • you need to create require-config.js file get reference here – Hitesh Oct 29 '18 at 10:56
  • I have this on theme-folder/require-config.js var config = { "map": { "*": { "flexslider":'Magento_Theme/js/jquery.flexslider.min', "amShopbyFilterSlider": "js/amShopby" } } }; Do I still need to create folders and file (theme-name/view/frontend/require-config.js) – thedeadlyone Oct 29 '18 at 11:01
  • try to append this 'Magento_Ui/Magento_Ui/js/view/messages.js':'[Namespace]_[Module]/js/view/messages.js' and check it work or not. – Hitesh Oct 29 '18 at 11:10
  • I accepted your answer because it's correct when you are on a module. But for your theme I think it's different? Isn't it just the folder? – thedeadlyone Oct 29 '18 at 12:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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