i am trying to include slick plugin into magento 2 through custom theme by requirejs but pub/static/_requirejs folder + files are not being generated on code deploy. file structure is following:

  1. /app/design/frontend/Vendor_Name/Theme_Name/requirejs-config.js
  2. /app/design/frontend/Vendor_Name/Theme_Name/web/js/slick.js and slick.min.js
  3. /app/design/frontend/Vendor_Name/Theme_Name/web/css/source/vendor/slick.less and slick-theme.less

Code for requirejs-config.js is as follows:

 `var config = {
           paths: {
               slick:'js/slick'
           },
           shim: {
               slick: {
               deps: ['jquery']
               }
           }
       };`

This is not a duplicate question, i have not found any solution on internet in last two days. Do let me know if any thing else needed regarding this question if it is not clear. I have followed this tutorial: https://inchoo.net/magento-2/magento-2-slick-carousel/

but i am stuck on point 7 as "requirejs-config.js" is not getting included may be because pub/static/_requirejs folder is not being generated on deploy

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

Please help me as i am stuck on this issue from last 2 days

Screenshot of View-source is: View-source of head block

  • deploy command generates pub/static/frontend, pub/static/adminhtml folders and their needed files but not _requirejs folder – Asad Kaleem Jul 8 at 14:10
  • _requirejs folder creates on magento 2 lower version i.e. on 2.1.x but not on Magento 2.2.x – Sukumar Gorai Jul 9 at 9:12
  • then how should I add 3rd party custom plugins in magento 2.2.x through require.js or any other way? – Asad Kaleem Jul 9 at 13:38
  • Do you want to add external js to your website? – Sukumar Gorai Jul 9 at 13:39
  • yes.. like slick carousel, scroll bars or any other plugins – Asad Kaleem Jul 9 at 13:40

You need to check the if requirejs-config.js loads slick or not on below path:

pub/static/frontend/vendor/theme/requirejs-config.js

If its exist there then check the page by view source if its loads the same there or not on below path:

http://example.com/pub/static/version1531144264/frontend/vendor/theme/en_US/requirejs-config.js

It should load there but according to the screenshot you have shared, requirejs-config.js is not loaded on your browser that means either you have created new layout which removed the block or you have removed some block which add requirejs to the page.

You can debug it by enabling luma theme and also disabled the other customization you have made.

Hope this helps!

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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