I am new to Magento2 and trying to figure out how RequireJS works in Magento.
Here is my situation:
I have the following module:
app/code/Mymodule/Test/view/frontend/requirejs-config.js
Here is the contents of this file:
var config = { map: { '*': { jQuery110: "Mymodule_Test/js/jquery-1.10.2", jqueryNoConflict: 'Mymodule_Test/js/jquery.no-conflict', flexslider: 'Mymodule_Test/js/jquery.flexslider-min', header: 'Mymodule_Test/js/store/header' } } };
My theme is in this place:
app/design/frontend/Mycompany/Basic
My Javascripts are in the following location:
app/code/Mymodule/Test/view/frontend/web/js/jquery.no-conflict.js app/code/Mymodule/Test/view/frontend/web/js/jquery.flexslider-min.js app/code/Mymodule/Test/view/frontend/web/js/store/header.js
In the PHTML file:
app/code/Mymodule/Test/view/frontend/templates/home.phtml
I added the lines:
require(['jqueryNoConflict', 'flexslider'],function($, flexslider){ (function($) { $(window).load(function () { $('.flexslider').flexslider(); }); })(jQuery); });
When I check my page in a browser, I get a 404 error with paths:
http://mag2.com.local/pub/static/frontend/Mycompany/Basic/en_US/flexslider.js
But if I changed the require [] line to this:
require(['Mymodule_Test/js/jquery.no-conflict', 'Mymodule_Test/js/jquery.flexslider-min'],function($, flexslider){ (function() { $(window).load(function () { $('.flexslider').flexslider(); }); })(jQuery); });
files are uploaded.
I also cleared the cache, my theme is correct, I executed the command:
php bin/magento setup:static-content:deploy
So I can not understand why my requirejs-config.js is not loading. I also followed the documentation.