0

In my requirejs-config.js file placed under [MyModule]/view/frontend, I include all my JS files like this:

var config = {
    paths: {
        "jquery.min": "MyVend_MyModule/js/jquery.min",
        "bootstrap": "MyVend_MyModule/js/bootstrap.min",
        "bootstrap-datepicker": "MyVend_MyModule/js/bootstrap-datepicker.min",
        "bootstrap-select": "MyVend_MyModule/js/bootstrap-select.min",
        "jquery.smoothState": "MyVend_MyModule/js/jquery.smoothState",
        "moment": "MyVend_MyModule/js/moment.min",
        ...
    },
    shim: {
        // 'libname' : ['dependency']
        "bootstrap": [ "jquery"],
        "bootstrap-datepicker": [ "jquery"],
        "bootstrap-select": [ "jquery"],
        "jquery.smoothState": [ "jquery"],
        "moment": [ "jquery"],
        ...
    }
};

My JS files are placed under [MyModule]/view/frontend/web/js and the file names match up, I can assure you.

Okay, so I do bin/magento setup:static-content:deploy and bin/magento setup:upgrade and such. The files are mirrored to /pub/static/... so I know they are there. When I refresh the page, the requirejs-config.js under /pub/static/_requirejs/... includes the content of my config file, so I know that is there as well. However, the javascript isn't being imported into the page, and I can confirm this by refreshing while looking at the Network tab (I am using Chrome). All it imports are the CSS files, which I declare under my layout xml files by:

<css src="MyVend_MyModule::css/bootstrap-select.min.css"/>
<css src="MyVend_MyModule::css/animate.min.css"/>
<css src="MyVend_MyModule::css/famfamfam-flags.css"/>
<css src="MyVend_MyModule::css/magnific-popup.css"/>
...

Those get imported correctly and they are there on the page. However, my JS files are not being imported, even though the files are there under /pub/static and it's in the requirejs-config.js file. Is there something I'm doing wrong? There is no error, which confuses me even more.

I will be posting this on StackOverflow as well, please do not mark as duplicate.

  • Did you set developer mode ? If true try to deploy asset files again and refresh – mrtuvn Apr 28 '17 at 8:31
  • @mrtuvn Yes, I did set developer mode and I did deploy asset files. – Mingle Li May 4 '17 at 1:05

Your Answer

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

Browse other questions tagged or ask your own question.