app/code/{vendor}/{module}/view/frontend/requirejs-config.js
var config = {
 map: {
 '*': {
 'Magento_Swatches/js/swatch-renderer' : 'Wac_SwatchName/js/swatch-renderer',
 'magento-swatch.renderer' : 'Magento_Swatches/js/swatch-renderer',
 'CustomName' : 'Vendor_Module/view/frontend/web/js/custom',
 }
 }
};
app/code/Vendor/Module/view/frontend/web/js/custom.js
$(document).on('swatch.initialized', function() {
 alert('test');
}
Only My Custom Js file Works When my Custom module load, But now Custom js not loading Properly ,Please Check my custom js file and requirejs-config file
 asked Jul 8, 2019 at 11:55
 
 
 
 Shafeel Sha 
 
 1,40516 silver badges34 bronze badges
 
 - 
 Remove the path view/frontend/webRaj Mohan R– Raj Mohan R2019年07月08日 11:59:24 +00:00Commented Jul 8, 2019 at 11:59
- 
 correct it : 'CustomName' : 'Vendor_Module/js/custom'Mukesh Prajapati– Mukesh Prajapati2019年07月08日 12:02:11 +00:00Commented Jul 8, 2019 at 12:02
1 Answer 1
Call correct module name and file name in requirejs-config.js
 "CustomName": "Vendor_Module/js/custom"
Need to declare require method in custom.js
require([
 "jquery"
], function($) {
$(document).on('swatch.initialized', function() {
alert('test');
});
});
 answered Jul 8, 2019 at 11:57
 
 
 
 Arunprabakaran M 
 
 3,52817 silver badges32 bronze badges
 
 - 
 Is it working fine?Arunprabakaran M– Arunprabakaran M2019年07月08日 12:05:00 +00:00Commented Jul 8, 2019 at 12:05
- 
 clear generated folderArunprabakaran M– Arunprabakaran M2019年07月08日 12:07:35 +00:00Commented Jul 8, 2019 at 12:07
- 
 rm -rf var/cache/ var/view_preprocessed/ generated/Arunprabakaran M– Arunprabakaran M2019年07月08日 12:07:52 +00:00Commented Jul 8, 2019 at 12:07
default