0

I would like to add External Library to My Custom Module.

I did below steps.

Vendor/Module/view/frontend/layout/default.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
 <link src="Vendor_Module::js/sweetalert.min.js"/>
</head>
<body>
 ......
</body>

Vendor/Module/view/frontend/requirejs-config.js

 var config = {
 map: {
 '*': {
 sweetalert: 'Vendor_Module/js/sweetalert.min',
 }
}};

** Note:-** JS Added I can see it in the source but there's error in the console too.

Uncaught Error: Mismatched anonymous define() module:

Console

Anything missing ??

asked May 14, 2018 at 13:07

1 Answer 1

2

I think this is because you're adding a require JS module directly to the page via XML rather than adding it as a dependency.

Try adding this as a dependency in your related JS file:

require(['sweetalert'], function(sweetAlert) {
 ... Your code
});
answered May 14, 2018 at 13:48

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.