1

I have a custom myjs.js file in my module. I have placed the myjs.js in Vendor/module/view/web/js/myjs.js, my requirejs-config is in Vendor/module/view/frontend

var config = {
    map: {
        '*': {
            'myjs': "vendor_module/js/myjs"
        }
    },

}; 

My js is not loading in pub/static/frontend. I want to create pub/static/frontend/theme/en_US/vendor_module/js/myjs.js on static -content:deploy.

Any suggestion on how can I load?

  • Try to deploy again after removing pub/static and var/ folders – Kishan Patadia Jan 9 '18 at 7:51
1

Put your Custom JS file in the following directory

app/code/Vendor/Module/view/frontend/web/js/myjs.js

And your require-config.js file is in directory

app/code/Vendor/Module/view/frontend/require-config.js

var config = {
    map: {
        '*': {
            myjs: 'Vendor_Module/js/myjs'
        }
    }
};

Please use the correct Naming convention as Magento follows.

After this regenerate the static files and flush the cache.

php bin/magento setup:static-content:deploy

php bin/magento cache:flush

0

app/code/vendor/module/view/frontend/requirejs-config.js

 var config = {
    map: {
        '*': {
            myjs: 'vendor_module/js/myjs'
        }
    }
 };

after use this command:

php bin/magento setup:static-content:deploy

php bin/magento cache:clean

  • It is in the same folder – akshay billore Jan 9 '18 at 8:38
  • It is in the same folder what? – Ravindrasinh Zala Jan 9 '18 at 9:03
  • my requirejs-config.js was in app/code/vendor/module/view/frontend/requirejs-config.js, that was not the problem. But the problem was with web folder. Anyways thank you for responding :) – akshay billore Jan 9 '18 at 13:13

Your Answer

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

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