1

I would like to add third-party dependency to Shopware6 e.g. https://github.com/vimeo/player.js/ for vimeo support. I'm not sure how to do it in the right way. Should I add dependencies to package.json somewhere or maybe create a vendor folder in my plugin where I will store this code file, that I can import at the point of use? Maybe there is some other way?

j.gil
  • 187
  • 1
  • 9

1 Answers1

1

If you want to add a dependency to your administration module, just create your package.json within src/Resources/app/administration and install your dependency. Those dependencies will be automatically detected by the webpack compiler, so you just have to import your library as normal within your module/component e.g

import package from 'package';

You don't need to ship the plugin later with the whole node_modules folder because Shopware is using only the compiled javascript ( administration:build ) for the plugin installation.

You can take a look at our Shopware-Maps Repo how we did it with the Mapbox dependency for example.

Christopher Dosin
  • 1,301
  • 9
  • 15