Domanda

I'm developing very small modules and would like to put all javascript 3rd party libraries in one place to better maintain/update them and to avoid duplicating across modules. According to the documentation,"Do not put custom JS files in the lib/web directory". So the best place is to place them in _core/view/frontend/web/js module ? Make module dependency to it and map js libraries in each others with requirejs-config.js ? Or am I misunderstanding the magento doc ?

I don't think it is a good idea to place them in my theme as it is not theme related.

È stato utile?

Soluzione

The usual solution I saw is to create "base" module and put such elements there. So if you create Vendor_Base and dependency in etc/modules.xml and etc/composer.json in child modules. If you want to deliver modules each one need to be bundled with this Vendor_Base. Custom js put in Vendor/Base/view/frontened/web/js and create Vendor/Base/view/frontend/require.js file to give them better name to use in child modules js files.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a magento.stackexchange
scroll top