I am trying to add in some 3rd party jQuery code to my Magento2 module. I want to have my own custom js file that will use the 3rd party code. Before I was adding the code into the header instead of using Magneto2's requireJS structure. I am not sure of the proper way to add in the files. The third party js file= slick.js
and my custom js file= configurator.js
.
I was under the impression that you are supposed to add a script type="text/x-magento-init
" in the template in which you add your custom js file in (I am note sure what to put here). Followed by adding a shim and path config for the 3rd part js in the require-config.js.
My file structure:
some of my code:
my custom js file:
require(['jquery','slick'], function($){
$(function(){
$('.main-gallery').slick();
});
});
my requirejs-config.js
var config = {
map: {
"*": {
slick: 'Briteskies_ProductConfigurator/js/slick-1.5.7/slick'
}
},
paths: {
"slick": 'js/slick-1.5.7/slick'
},
"shim": {
"slick" : ["jquery"]
}
};
Any input would be great, thanks!